[Go language] Learn Go--init () method from Docker source code and identifier first letter case

Source: Internet
Author: User
Init () method

If you want to do some initialization work in a go file, you can put the code in the Init () method.

The init () method is executed first.

// initializationof package}

Note: It is not an input parameter and a return parameter.

Identifier first letter case sensitivity

When identifier (e.g. Constant,variable,type,function,struct field, ...) The first letter of the name is capitalized, which means that the identifier is visible outside the package;

function similar to public.

Conversely, when the first letter of the identifier is lowercase, it means that the idenfitier is visible only within the package;

Similar to the role of private.

Note: Whether outside the package is visible and the go language reflection will have a certain relationship, if it is only visible within the package, there will be a problem in the reflection lookup.

Related Article

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.