数组是固定长度的,依稀让我想起了VB;切片是动态的;map一般是键值对
package main
import (
"fmt"
)
func main() {
var username string
fmt.Println(username)
username = "abc"
fmt.Println(username)
//array
names := [2]string{"a", "b"}
fmt.Println(names)
//slice
names2 := [...]string{1: "Jan", 2: "Feb"}
fmt.Println(names2)
//map
ages := map[string]int{
"jimmy": 31,
"tom": 32,
}
ages["lily"] = 18
fmt.Println(ages)
ages["lucy"] += 10
fmt.Println(ages)
}