如何从go1.13中的go程序生成文档

如何从go1.13中的go程序生成文档,go,Go,这里有一个小程序 // Copyright Some Company Corp. // All Rights Reserved package main // here are the imports import ( "fmt" ) // function to say hello func hello() { fmt.Println("hello world") } // Main function here func main() { hello() }

这里有一个小程序

// Copyright Some Company Corp.
// All Rights Reserved
package main


// here are the imports
import (
    "fmt"
)

// function to say hello
func hello() {
    fmt.Println("hello world")

}

// Main function here
func main() {
    hello()
}
如何从这段代码生成html文档

结果:

godoc -html  github.com/bussiere/GoTestDoc 
flag provided but not defined: -html
usage: godoc -http=localhost:6060
  -analysis string
        comma-separated list of analyses to perform (supported: type, pointer). See http://golang.org/lib/godoc/analysis/help.html
  -goroot string
        Go root directory (default "/usr/lib/go-1.13")
  -http string
        HTTP service address (default "localhost:6060")
  -index
        enable search index
  -index_files string
        glob pattern specifying index files; if not empty, the index is read from these files in sorted order
  -index_interval duration
        interval of indexing; 0 for default (5m), negative to only index once at startup
  -index_throttle float
        index throttle value; 0.0 = no time allocated, 1.0 = full throttle (default 0.75)
  -links
        link identifiers to their declarations (default true)
  -maxresults int
        maximum number of full text search results shown (default 10000)
  -notes string
        regular expression matching note markers to show (default "BUG")
  -play
        enable playground
  -templates string
        load templates/JS/CSS from disk in this directory
  -timestamps
        show timestamps with directory listings
  -url string
        print HTML for named URL
  -v    verbose mode
  -write_index
        write index to a file; the file name must be specified with -index_files
  -zip string
        zip file providing the file system to serve; disabled if empty
因此,自上次以来,似乎很多事情都发生了变化。
而且似乎很难找到最新的教程和文档来为go1.13中的golang制作文档,这可能是您需要的

godoc -html <package-name>
godoc-html
有关更多详细信息,请参阅

  • 将包文件夹移动到
    GOPATH
    目录下
  • 使用
    godoc
    为go项目生成文档

    • 生成html文档的步骤
    • 备选方案:
    现在您可以访问
    http://localhost:6060/pkg/github.com/username/my-package
    浏览软件包的文档

    $GOPATH/src/github.com/username/my-package
    
    godoc -html  github.com/username/my-package
    
    godoc -http=:6060