Golang has the inbuilt package called strconv that provide functions that convert int to string. To convert the int type to string type, you can use one of the following methods:

  1. strconv.FormatInt: FormatInt returns a string representation of i in the given base, for 2 <= base <= 36. The result uses the lower-case letters ‘a’ to ‘z’ for digit values >= 10.

  2. strconv.Itoa: Itoa is shorthand for FormatInt(int64(i), 10)

Golang int/int64 to string

Go (Golang) provides string and integer conversion directly from a package coming from the standard library strconv.

To convert an integer value to string in Golang, we can use the FormatInt function from the strconv package.

#go #golang

How To Convert Golang Int To String Example
3.40 GEEK