Generating documentation
This section discusses how to create documentation for your Go code using the code of the sqlite06
package as an example. The new package is renamed and is now called document
—you can find it in ch06/document
in the GitHub repository of the book.
Go follows a simple rule regarding documentation: in order to document a function, a method, a variable, or even the package itself, you can write comments, as usual, that should be located directly before the element you want to document, without any empty lines in between. You can use one or more single-line comments, which are lines beginning with //
, or block comments, which begin with /*
and end with */
—everything in between is considered a comment.
It is highly recommended that each Go package you create has a block comment preceding the package declaration that introduces developers to the package, and also explains what the package does.
Instead of presenting the entire...