【问题标题】:How to create document with godoc?如何使用 godoc 创建文档?
【发布时间】:2019-04-10 18:40:37
【问题描述】:

我在应用程序中对函数和包创建了简单的注释 我尝试了 godoc -html 和我的应用程序以及结果

<!--
    Copyright 2009 The Go Authors. All rights reserved.
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.
-->

<!--
        Note: Static (i.e., not template-generated) href and id
        attributes start with "pkg-" to make it impossible for
        them to conflict with generated attributes (some of which
        correspond to Go identifiers).
-->

        <script type='text/javascript'>
        document.ANALYSIS_DATA = ;
        document.CALLGRAPH = ;
        </script>



                <p>
Package main provides logic ...
</p>

为什么我没有看到我的其他文件?以及为什么包裹的&lt;p&gt; 有空格

// Package main provides logic.
package main
import (

}

some types.....

func main() {
}

// doLogic .....
// .....
// ....
func (sm *myI) doLogic (s *myStruct) bool {

}

【问题讨论】:

    标签: go godoc


    【解决方案1】:

    默认情况下未记录未导出的标识符。至少设置?m=all 才能看到它们:

    godoc服务的网页的展示方式可以通过“m”URL参数来控制;它接受以逗号分隔的标志名称列表作为值:

    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 then the extracted documentation
    

    例如,https://golang.org/pkg/math/big/?m=all 显示了 package big 的所有(不仅仅是导出的)声明的文档。 https://godoc.org/golang.org/x/tools/cmd/godoc

    【讨论】:

    • 我需要在命令 godoc -html -src c:/Users/go/src/myProject 中添加什么?
    • 我可以用 godoc -http=:6060 运行它吗? PS我如何导出方法?
    • 我运行这个命令 godoc -http=:6060 -goroot=$GOHOME 然后我运行localhost:6060?m=all 然后我成功获得了结构体而不是函数
    • 默认的godoc无法记录主包。见stackoverflow.com/questions/21778556/…
    猜你喜欢
    • 2020-07-01
    • 2012-11-11
    • 2021-09-19
    • 2019-07-22
    • 2021-07-15
    • 2017-06-08
    • 1970-01-01
    • 2019-03-15
    • 2018-08-27
    相关资源
    最近更新 更多