package main import ( "fmt" ) func main() { s := make([]string, 10) fmt.Println(s) fmt.Println(len(s)) fmt.Println("--------------------------") s = append(s, "a") s = append(s, "a", "b") fmt.Println(len(s)) fmt.Println(s[10:13]) fmt.Println("--------------------------") s[0] = "c" s[1] = "b" fmt.Println(len(s)) fmt.Println(s) fmt.Println("--------------------------") fmt.Println(s[:13]) fmt.Println(s[1:13]) fmt.Println("--------------------------") }
输出:
有疑问加站长微信联系(非本文作者)