Go: Append string to byte slice
You can append a string s
to a byte slice using the s...
notation:
var buf []byte
buf = append(buf, 'a', 'b')
buf = append(buf, "cd"...)
fmt.Println(buf) // [97 98 99 100]
Comments
Be the first to comment!