append()只能附加与切片的元素类型匹配的类型的值:
func append(slice []Type, elems ...Type) []Type
所以,如果你有元素
[]interface{},你必须包装您最初string的
[]interface{}以能够使用append():
s := "first"rest := []interface{}{"second", 3}all := append([]interface{}{s}, rest...)fmt.Println(all)输出(在Go Playground上尝试):
[first second 3]



