福哥答案2020-11-02:
打印空字符串。s:=make([]string,10),s中已经有10个元素,append元素,s就有11个元素了。前10个元素没初始化,就是10个空字符串,最后1个字符串是test。
golang代码如下:
package main import "fmt" func main() { fmt.Println("----start----") s := make([]string, 10) s = append(s, "test") fmt.Println("字符串是:", s[0]) fmt.Println("----end----") }
测试结果如下: