1、
Short declare variables
In the function, `: =` simple assignment statement in clear type of place, it may be used instead var
definition.
Each statement outside the function must begin with the keyword ( `var`,` func`, etc.), `: =` structure can not be used outside the function
2、
basic type
Go basic types are Basic types
BOOL String int Int32 int8 int16 int64 uint uint8 uint16 uint32 UInt64 UIntPtr byte // alias for uint8 rune // int32 alias // represent a Unicode code float32 float64 complex64 complex128
3、
Type Conversion
Expression T(v)
value v
is converted to type `T`.
Something about the value of the conversion:
were int = 42 was f float64 = float64 (i) were u uint = uint (f)
Or, more simple form:
i := 42 f := float64(i) u := uint(f)
Go and C are different from the needs of the project at the explicit conversion between different types of assignments.
4、
constant
Definition and similar variables constant, but the use of const
keywords.
Constant value can be a character, string, Boolean, or numeric type.
Constants can not use the :=
syntax definition.
5, switch statements
the: = runtime.GOOS
switch os {
case "darwin":
fmt.Println("OS X.")
case "linux":
fmt.Println("Linux.")
default:
fmt.Printf("%s.", os)
}
No terms of the switch
`Switch with no conditions as switch true`.
This configuration makes it possible to form a clearer preparation of long chain if-then-else.
6、