go type it belongs to a new type of use after the alias.
+1 go pointer can not remove an address.
go no front ++, - (++ a wrong)
(Note that the array can be compared, slice can not be compared) with == compare arrays
The same dimensions and containing the same number of elements in the array can be compared
Each element of the same are equal
& ^ Bitwise cleared
1 &^ 0 -- 1
1 &^ 1 -- 0
go-for
Execute an infinite loop
for {}
go not need to add break in a switch inside, the statement himself with break
switch support case which fill many conditions
E.g:
switch {
case 0<=NUM &&NUM <=3
fmt.print(1)
case 5,6:
-----------------------
And array slice (slice shared memory structure)
var a [3] int // declared and initialized to the default value of zero
}
Cycle used to:
for i:=0;i<len(arr);i++ {}
Recommended for idx, e: = range arr {}
Array interception method (does not support negative acquisition)
E.g:
a :=[...]int{1,2,3,4,5}
a[1:2]//2
a[1:3]//2,3
and [1: only (a)] // 2,3,4,5
a[1:]//2,3,4,5
a[:3]//1,2,3
And an array of difference slices, the length of the array is, the length of the slice is not
Append padding data slice using
make (arr len, cap) // create slices
If a slice with a time append to go, then the array will be retrieved in an increase in the cap
E.g:
make(a,3,5)
fmt.print(a)//0,0,0
a=append(a,666)
fmt.print(a)//0,0,0,666
When a parameter into slices, if not enough space will be full-length 2 *
E.g:
s:=[]int{}
for i:=0;i<10;i++ {
s=append(s,i)
t.log (len (s), cap (s)) // len increments of one by one, but the cap will be doubled in increments would not be enough
}
// cap special
----------
map Type
m3: = make (map [int] int, 10) // this time the printed length of 0, when the make and use the map when the map is actually the second parameter
When visiting Key does not exist, since it returns a value of zero, not by returning nil to determine whether there is an element
-----------