python | golang | init | get | set | extend/update | find | index | size | loop |
list | list | l := list.New() | l.PushBack(1) l.InsertAfter(value, l.Front()) | dest_list.PushBackList(src_list) | l.Len() | for e := l.Front(); e != nil; e = e.Next() { fmt.Print(e.Value) } | |||
array | primes := [6]int{2, 3, 5, 7, 11, 13} a := make([]int, 5) | a[0] b := a[1:4] var b []int = a[1:4] | a[0] = "hello" | ||||||
var x []int var pow = []int{1, 2, 4, 8, 16, 32, 64, 128} | x[0] | x = append(x, 1, 2, 3) | for i, v := range pow { fmt.Printf("2**%d = %d\n", i, v) } | ||||||
tuple | |||||||||
dict | m := make(map[string]int) m := map[string]int{} m := map[string]int{ "a": 1, "b": 2, } | i := m["route"] | m["route"] = 66 | len(m) | for key, value := range m { fmt.Println("Key:", key, "Value:", value) } | ||||
set |