Go basic--02 (some tricks, some rules)

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. Go Language Learning notes
1. Some skills Group Declaration In the go language, it also declares multiple constants, variables,Or when importing multiple packages, you can use in the form of a group . For example, the following code:
Import "FMT" import "OS" Const i = 100const Pi = 3.1415const prefix = "Go" var i intvar pi float32var prefix string can be grouped into the following form Type: Import (///Group way to declare    imports multiple packages "FMT" "OS") const (///group declaratively declare    multiple Constants i = 100PI = 3.1415prefix = "Go_") var (//Group BY way of declaration    declaring multiple variables I intpi float32prefix string)
Unless explicitly set to a different value or iota, each const groupThe first Constantsis set to its 0 value by default, and the second and subsequent constant is set by default to the value of the constant preceding it., if the value of the preceding constant is iota, it is also set to iota.
2, some rules of Go program designGo is so concise because it has some the default behavior:
    • -  capital letters beginning with variable is exportable, that is Other packages can read , which is the common variable;
    •     lowercase letters are non-exportable and are private variables.  
    • -  capital letters function
    •     lowercase letters are private functions that have private keywords.

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.