To summarize:
strconv.Itoa doesn't seem to work
strconv.Itoa
accepts int
, which is signed integer (either 32 or 64 bit), architecture-dependent type (see Numeric types).
I need to convert an uint32 to string
- Use
fmt.Sprint
- Use
strconv.FormatUint
The better option is strconv.FormatUint
because it is faster, has less memory allocations (benchmark examples here or here).
A cast string(t) could have been so much easier.
Using string
does not work as some people expect, see spec:
Converting a signed or unsigned integer value to a string type yields a string containing the UTF-8 representation of the integer. Values outside the range of valid Unicode code points are converted to "\uFFFD".
This function is going to be removed from Go2, see Rob Pike's proposal