This is a creation in Article, where the information may have evolved or changed.
Reprint: http://www.liguosong.com/2013/07/07/golang%E7%9A%84%E5%B0%8F%E6%80%BB%E7%BB%93/
VAR create variable
Const Create constant
Iota This keyword is used when declaring an enum, its default start value is 0, each call plus 1
Map is the concept of the dictionary in Python, its format for Map[keytype]valuetype map reading and setting is similar to slice, by key to operate, but only the slice index can only be ' int ' type, and map many types, can be an int, which can be a string
Make memory allocations for built-in types (map, slice, and channel)
New for various types of memory allocations
Goto jumps to a label that must be defined within the current function
The Func keyword func is used to declare a function funcname
Defer deferred execution code, similar to destructor
Panic interrupt the original control process
Recover function to resume interrupts
Import the package file
Some rules of Go programming
- The variable that starts with the capital letter is exportable, which is the common variable that the other package can read, and the lowercase letter begins with a non-exportable, private variable.
- A function that starts with a capital letter is the same as a public function with a common keyword in class, and a private function that starts with a secret keyword.
There are two reserved functions in go: the init function (which can be applied to all package) and the main function (can only be applied to package main). These two functions cannot have any parameters and return values when they are defined. Although it is possible to write any number of INIT functions in a package, it is strongly recommended that users write only one init function per file in a single document, whether for readability or later maintainability.
The GO program automatically calls Init () and main (), so you don't need to call these two functions anywhere. The INIT function in each package is optional, but the package main must contain a main function.