This is a creation in Article, where the information may have evolved or changed.
Today to see no-smell video, 2 to 5 of the content, some summaries are scattered in the following:
1. Main function as a program entry, must exist and in Main's package
2. Type is used to declare a new type, struct,interface
3. import Var const and so on can be () to declare multiple, but do not call the function will be error, to ensure the speed. var only uses parentheses when declaring global variables, and declaring variables in a function is not possible.
4. Import can take aliases such as
Import Std "FMT"
Import. "FMT", which calls the FMT function directly.
5. The contract function name lowercase is private, the initial capitalization is public.
6. BOOL type only true and False
7. Int/uint 32-bit 64-bit according to the platform,
int8-128~127
Uint8 0~255
BYTE unit8 aliases
Rune Int32
float32 float64 no double accurate to 7/15 decimal places
UIntPtr
Other such as array struct string slice map Chan inteface func
8. Type 0 value, declared default value, 0,false, empty string, NULL the maximum minimum value in the math package
9. var a int = 321 you can omit int auto-inference at this time
or directly b:=1 Miss Pascal (: used instead of Var, so the global is not available), local variables of multiple declarations, using A,B,C,D = 1,2,3,4 such a parallel way.
10. Blank symbol _ to ignore replication, a,_,c:=1,2,3
11. Type conversion B[:]=int (a), depending on whether it has been declared or not
var a int = 64
B: = string (a) output @
Otherwise introduce the StrConv package, using the ITOA function
13. In a constant group, the value is a constant expression on the previous line, without assigning a value. And the initialization rules are consistent, such as the first row, a second row must be c,d, the same number
Iota in a constant group, each of which is defined by a plus 1, starting from 0
If statements are not enclosed in parentheses, can be initialized, separated by semicolons, and left curly braces must be one line
The switch statement is flexible, but executes the first match to jump out, otherwise add Fallthrough
The goto break continue can be used with tags to jump out of multi-layer loops