Value types and application types
Arrays and strings are value types, slices, mappings, channels are value types, and assignments need to be noted.
1 Package Main2 3 Import (4 "FMT"5 )6 7 Func Main () {8 //Array9A1: = [3]int{1,2,3}TenA2: =A1 Onea2[0] =2 AFmt. PRINTLN (A1)//print:1 2 3 -Fmt. PRINTLN (A2)//Print:2 2 3 - //string theS1: ="123" -S2: =S1 -S2 ="223" -Fmt. Println (S1)//Print 123 +Fmt. PRINTLN (S2)//Print 223 - //slices +Slice1: = []int{1,2,3} ASlice2: =Slice1 atslice2[0] =2 -Fmt. Println (Slice1)//Print 2 2 3 -Fmt. Println (SLICE2)//Print 2 2 3 - //Map -M1: = Make (map[int]string) -m1[1] ="1" inM2: =M1 -m2[1] ="2" toFmt. PRINTLN (M1)//Print 1:2 +Fmt. Println (m2)//Print 1:2 - //Chan theC1: = Make (chanBOOL) *C2: =C1 $ go func () {Panax NotoginsengV: = <-C2 -Fmt. Println (v)//Print True the }() +C1 <-true A}
Go Language Details