引自 Go的参考append
作为一种特殊情况,将字符串附加到字节切片是合法的,如下所示:
slice = append([]byte("hello "), "world"...)
但我发现我不能像这个片段那样做:
package main
import "fmt"
func main(){
a := []byte("hello")
s := "world"
a = append(a, s) //*Error*: can't use s(type string) as type byte in append
fmt.Printf("%s",a)
}
我做错了什么?
相关分类