引用reference of append
of Go年前的话
作为一种特殊情况,将字符串附加到字节片是合法的,如下所示:
但我发现我不能这样做,因为下面的代码片段是这样的:
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)
}
我做错了什么?