Citazione dal reference of append
of GoPerché non posso aggiungere una stringa a una slice di byte come specificato nel riferimento Go?
Come caso speciale, è legale per aggiungere una stringa ad una fetta di byte, in questo modo:
slice = append([]byte("hello "), "world"...)
ma trovo che non posso farlo come questo frammento:
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)
}
Cosa ho fatto di sbagliato?
Felice di dare a qualcuno il loro primo 10. :) – twotwotwo
@twotwotwo È molto gentile da parte tua :) –