I need to convert an array of strings to an array of byte arrays. This code works, but the repeated append
seems distasteful to me. Is there a better way?
input := []string{"foo", "bar"}
output := [][]byte{}
for _, str := range input {
output = append(output, []byte(str))
}
fmt.Println(output) // [[102 111 111] [98 97 114]]