An idiomatic way of documenting a Golang program, consisting of a single main.go file
I wrote a Go tool that reads files and produces output based on input. It consists of a single main.go file. Where can I document what the tool does in order to use godoc (or just be idiomatic)?
// Should I explain it here?
package main
// Or here?
func main() {
// code!
}
// Or somewhere else?
+3
source to share
1 answer
To document a command for godoc or godoc.org, write the command documentation in the package comment.
// Command foo does bar.
package main
func main() {
// code!
}
See the comment at stringer.go and the stringer documentation for an example.
By default, godoc and godoc.org hide all other comments in the package named "main".
+9
source to share