Follow the "GO in ACTION" book.
It should be the second time Oh ~ ~
Package Mainimport ("FMT") func main () {array: = [5]*int{0:new (int), 3:new (int)}*array[3] = 50/*for k, V: = range Array { Fmt. Println (*array[k], K, v)}*/fmt. Println (*array[3]) var array1 [3]*stringarray2: = [3]*string{new (String), new (string), new (string)}*array2[0] = "Red" * ARRAY2[1] = "Blue" *array2[2] = "Green" array1 = array2*array1[1] = "Black" FMT. Println (array1) fmt. Println (array2) for k, V: = Range Array1 {fmt. Println (*array1[k], K, *v)}for k, V: = Range Array2 {fmt. Println (*array2[k], K, *v)}slice: = []int{10, +, +, 50}newslice: = slice[1:3:3]newslice[1] = 35newSlice = Append (new Slice, Newslice = append (newslice) Newslice = append (Newslice,) Newslice = append (Newslice, all) Slice = Append (slic E, slice = append (slice, d) slice = append (slice, d) newslice = Append (Newslice, +) Slice1: = []int{10, +,-40}new Slice1: = Append (Slice1, a) slice1[2] = 200newslice1[2] = 2000fmt. Println (Slice) fmt. Println (Newslice) fmt. Println (Slice1) fmt. Println (NewSlice1) for index, Value: =Range Slice {fmt. Printf ("Index:%d value:%d\n", index, value)}for index: = 2; Index < Len (slice); index++ {fmt. Printf ("Index:%d Value:%d\n", index, Slice[index])}source: = []string{"Apple", "Orange", "Plum", "Banana", "Grape"}news Ource: = source[2:3:4]fmt. Println (source) fmt. Println (newsource) S1: = []int{1, 2}s2: = []int{3, 4}fmt. Printf ("%v\n", append (S1, S2 ...)) Colors: = map[string]string{"AliceBlue": "#f0f8ff", "Coral": "#ff7F50", "Darkgray": "#a9a9a9", "Forestgreen": "#22 8b22 ",}delete (Colors," Coral ") for key, value: = Range colors {fmt. Printf ("Key:%s value:%s\n", Key, Value)}}
Go basic data structure exercises: arrays, slices, maps