dongzhuang5741 2019-02-06 16:42
浏览 160
已采纳

如何在golang中获取func文档?

How can I get the func description within go code?

// My very nice description
func myFunc() { ... }

I'd like to have My very nice description.

Getting the name of a func is pretty straight forward:

runtime.FuncForPC(reflect.ValueOf(myFunc).Pointer()).Name()

Is there something similar for the documentation? It would be ok for me to parse the original go file. Any shortcuts there?

  • 写回答

3条回答 默认 最新

  • duanlei2150 2019-02-06 17:06
    关注

    Use the go/doc package to extract documentation from source code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?