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.