我试图将特定的本地围棋文件作为文档网页提供服务,但无法实现.
official godoc documentation人说:
使用-http标志(即godoc命令),它作为Web服务器运行,并将文档显示为网页.
user_me$ godoc -http=:6060
这确实会创建类似于go页面的内容,但它不会呈现我想要呈现的特定文件.所以我试着提供我想要的文件名:
user_me$ godoc -http=:6000 hello.go
但是,它只回复说:
usage: godoc package [name ...]
godoc -http=:6060
-ex=false: show examples in command line mode
-goroot="/usr/local/go": Go root directory
-html=false: print HTML in command-line mode
-http="": HTTP service address (e.g., ':6060')
-httptest.serve="": if non-empty, httptest.NewServer serves on this address and blocks
-index=false: enable search index
-index_files="": glob pattern specifying index files;if not empty, the index is read from these files in sorted order
-index_throttle=0.75: index throttle value; 0.0 = no time allocated, 1.0 = full throttle
-links=true: link identifiers to their declarations
-maxresults=10000: maximum number of full text search results shown
-notes="BUG": regular expression matching note markers to show
-play=false: enable playground in web interface
-q=false: arguments are considered search queries
-server="": webserver address for command line searches
-src=false: print (exported) source in command-line mode
-tabwidth=4: tab width
-templates="": directory containing alternate template files
-timestamps=false: show timestamps with directory listings
-url="": print HTML for named URL
-v=false: verbose mode
-write_index=false: write index to a file; the file name must be specified with -index_files
-zip="": zip file providing the file system to serve; disabled if empty
我还试过:
user_me$ godoc -url="localhost:8080" hello.go
但没用.
我还试过:
godoc -server=localhost:8080 hello.go
但它的回答是:
2014/07/01 10:45:56 open /usr/local/go/src/pkg/hello.go: no such file or directory
我甚至试着自己生成html:
godoc -html hello.go > hello.html
与上述错误相同.
我还try 了(因为它抱怨pkg目录中没有文件):
godoc -html -goroo=$GOPATH hello.go > hello.html
最后,我放弃了.我不知道godoc是怎么运作的.我安装了hello.go程序,这样我就可以在工作区的pkg文件中找到一些东西.如何生成包含代码文档的网页?