Integer Conversions: Unicode vs. String Values

We can convert an integer value into a string in two main ways: using string() and using a function from the strconv package. However, the two methods are fundamentally different.

Converting from int to string

The string() function converts an integer value into a Unicode code point, which is a single character, whereas functions such as strconv.FormatInt() and strconv.Itoa() converts an integer value into a string value with the same representation and the same number of characters.

Coding example

This is illustrated in the intString.go program—its most important statements are the following:

Get hands-on with 1200+ tech skills courses.