Warum kann ich nicht Anhängen string zu byte-slice als Referenz angegeben?

Zitat aus der Referenz von append Go

Als besonderer Fall, es ist legal, append einen string in ein byte-slice, wie diese:

slice = append([]byte("hello "), "world"...)

Aber ich finde, ich kann nicht tun, als dieses snippet:

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)
}

Was habe ich falsch gemacht?

InformationsquelleAutor armnotstrong | 2015-01-14
Schreibe einen Kommentar