Convert an integer to a byte array
I have a function which receives a byte array (slice?), what is the best way to go about this?
err = a.Write([]byte(myInt))
I guess I could go the long way and get it into a string and put that into bytes, but it sounds ugly and I guess there are better ways to do it.
I have a function which receives a byte array (slice?), what is the best way to go about this?
err = a.Write([]byte(myInt))
I guess I could go the long way and get it into a string and put that into bytes, but it sounds ugly and I guess there are better ways to do it.
No comments:
Post a Comment