为了账号安全,请及时绑定邮箱和手机立即绑定

Godooc不会读取我的代码,或者godoc无法读取anonymouse函数?

Godooc不会读取我的代码,或者godoc无法读取anonymouse函数?

Go
慕标琳琳 2022-08-24 20:14:03
最近我试图记录我的代码,但我在使用时遇到了一些麻烦,因为当我运行时没有出现一些函数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 definitionfunc 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) 
查看完整描述

1 回答

?
杨__羊羊

TA贡献1943条经验 获得超7个赞

您可以参考此文档:https://pkg.go.dev/golang.org/x/tools/cmd/godoc


The presentation mode of web pages served by godoc can be controlled with the "m" URL parameter; it accepts a comma-separated list of flag names as value:


- all   show documentation for all declarations, not just the exported ones

- methods   show all embedded methods, not just those of unexported anonymous fields

- src   show the original source code rather than the extracted documentation

- flat  present flat (not indented) directory listings using full paths


For instance, https://golang.org/pkg/math/big/?m=all shows the documentation for all (not just the exported) declarations of package big. 

?m=all文件所有申报,包括非出口方式


查看完整回答
反对 回复 2022-08-24
  • 1 回答
  • 0 关注
  • 90 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号