最近我试图记录我的代码,但我在使用时遇到了一些麻烦,因为当我运行时没有出现一些函数godocgodoc -http:localhost:6060
这是我的代码的样子:
type MongoDBInterface interface {
ExecuteTransaction(operation func(mongoClient MongoDBInterface) error) error
Count(tableName string, clause bson.M) (int, error)
Distinct(tableName, fieldName string, clause bson.M) ([]interface{}, error)
InsertOrUpdate(tableName string, clause bson.M, data models.BaseModelInterface) (primitive.ObjectID, error)
InsertOrUpdateFields(tableName string, clause bson.M, data interface{}) (primitive.ObjectID, error)
Insert(tableName string, data models.BaseModelInterface) (primitive.ObjectID, error)
Update(tableName string, clause bson.M, data models.BaseModelInterface) error
UpdateFields(tableName string, clause bson.M, data interface{}) error
FindOne(tableName string, clause, opt bson.M, result interface{}) error
FindMany(tableName string, clause, opt bson.M, result interface{}) error
Truncate(tableName string) error
Delete(tableName string, clause bson.M) error
Aggregate(tableName string, pipelines interface{}, result interface{}) error
EnsureCollections() error
}
type mongoDB struct {
session mongo.Session
db *mongo.Database
ctx context.Context
isTransactionEnabled bool
isConnected bool
connString string
}
// NewMongoDB definition
func NewMongoDB() MongoDBInterface {
mongoClient := new(mongoDB)
mongoClient.ctx = context.Background()
dbHost := os.Getenv("DB_HOST")
if dbHost == "" {
dbHost = "localhost"
}
dbUser := os.Getenv("DB_USERNAME")
if dbUser == "" {
dbUser = "dbadmin"
}
问题是永远不会渲染,但我需要它被记录下来,你们能向我解释一下发生了什么吗?或者,也许您可以给我一些记录Go代码的解决方案和提示。godocfunc (s *mongoDB)
杨__羊羊
相关分类