godoc using the method described

A, go doc Profile

Godoc is go language documentation tool, similar documentation tool godoc, similar to the Docstring Python and Java Javadoc
Godoc to generate HTML or text type of document by parsing Go code contains comments.

Second, the rules of engagement

godoc
Go annotation rule is very simple, when writing a comment for types, variables, constants, functions, or packages, written in the form of general comments directly in front of these statements, the middle row can not be left blank. Godoc behind these comments and statements connected together to achieve the purpose of the document.

After the Notes // 1. spaces
// 这是一行注释
package main
2. Write the comment line next to the keyword, it will not be recognized
// 不会被识别

// 会被识别
package main

// 不会被识别

// 会被识别1
// 会被识别2
func main(){

}
3. The number of comment lines should not exceed 3 lines
4. Known bug NOTE: BUG (who)

godoc output will ignore those statements are not adjacent top notes, with one exception, it is the comment BUG (who) begin with. These notes will be identified as a known bug, and BUGS region contained in the document.

// 注释
package main


// BUG(who)  //会被识别,放入文档的Bugs区


const a = 8

Third, use the command

.Go documentation directory is first in line to enter the command to be executed
Example: My test.go on the C: / GoProject / src / test / directory
need to enter the command line C: / GoProject / src / test /
then execute the command

 godoc -http=:6060     //6060是godoc提供的默认端口

In the browser, enter localhost: 6060
, you can enter godoc site, check their documentation required in the address bar enter the path localhost: 6060 / pkg / test

Guess you like

Origin www.cnblogs.com/niuben/p/12387357.html