Go Language Notes

Source: Internet
Author: User
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
)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.