This is a created article in which the information may have evolved or changed.
Go Language Annotation Instance Code tutorial-Go supports C-style */*/block annotations, and also supports C + + style//line comments. Of course, line comments are more general, and block annotations are primarily used for detailed descriptions of packages or for masking large chunks of code.
Each package should have a package annotation, which is the block annotations before the packages. For multiple-file packages, package annotations need to appear in only one file, whichever is. Package annotations should introduce this package and provide the corresponding information for this package as a whole. It first appears on the Godoc page to arrange for subsequent detailed documentation.
If the package is simple, the comment can be brief.
Annotations do not require extra typography such as star banners. The resulting result may not be equal to the width of the font, so do not rely on spaces to align, godoc, similar to gofmt care for these. Finally, annotations are text that is not interpreted, and HTML and others such as _this_ are copied as is, so you should avoid using them.
In the package, the note immediately preceding the top-level declaration as the text of this declaration, each export (uppercase) name in the program should have a text annotation.
It is best to have a complete sentence. The first sentence should be summed up in a sentence that begins with the name of the statement.
The declaration syntax of Go allows grouping. A single text annotation can lead to a set of associated constants or variables. Because the entire set of statements is presented together, the annotations can be very sketchy:
For private names, groups can also indicate the connection between them, such as a series of variables protected by a mutex.
var ( countlock sync. Mutex inputcount uint32 outputcount uint32 errorcount UInt32
)