Go string to ascii byte array

user181351 picture user181351 · Jul 30, 2010 · Viewed 60.7k times · Source

How can I encode my string as ASCII byte array?

Answer

cthom06 picture cthom06 · Jul 30, 2010

If you're looking for a conversion, just do byteArray := []byte(myString)

The language spec details conversions between strings and certain types of arrays (byte for bytes, int for Unicode points)