Use the strconv package's Itoa function.

For example:

package main

import (
    "strconv"
    "fmt"
)

func main() {
    t := strconv.Itoa(123)
    fmt.Println(t)
}
Answer from Klaus Byskov Pedersen on Stack Overflow
๐ŸŒ
Go Packages
pkg.go.dev โ€บ strconv
strconv package - strconv - Go Packages
FormatComplex converts the complex number c to a string of the form (a+bi) where a and b are the real and imaginary parts, formatted according to the format fmt and precision prec. The format fmt and precision prec have the same meaning as in FormatFloat. It rounds the result assuming that the original was obtained from a complex value of bitSize bits, which must be 64 for complex64 and 128 for complex128. func FormatFloat(f float64, fmt byte, prec, bitSize int) string
Discussions

Convert string to integer type in Go? - Stack Overflow
If you need to parse strings really fast, you can use faiNumber package. faiNumber is the fastest golang string parser library. All of faiNumber's function was benchmark to run way faster than the strconv package. faiNumber supports parsing strings of decimal, binary, octal, hex to an int32, ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Which is the best way to convert int to string in golang ?
  1. is plain wrong

  2. is the most lightweight (in terms of dependency and performance)

  3. is the most flexible

More on reddit.com
๐ŸŒ r/golang
7
6
September 17, 2018
Strings slices to Integer Slices the most optimal way
Do you need the most optimized solution? But anyway, a simple optimization is to allocate the slice up front instead of appending to it and growing it to the target length: integers := make([]int, len(lines)) for i, line := range lines { ... integers[i] = n ... More on reddit.com
๐ŸŒ r/golang
13
1
December 1, 2021
convert epoch time to a human readable string

time.Unix, and time.Time.Format. http://golang.org/pkg/time/

http://play.golang.org/p/PALkclLdyq

More on reddit.com
๐ŸŒ r/golang
4
4
May 31, 2012
๐ŸŒ
ByteSizeGo
bytesizego.com โ€บ blog โ€บ convert-int-to-string-golang
How to convert an int to string in Golang
September 10, 2024 - The most straightforward and commonly used way to convert an integer to a string in Go is by using the strconv.Itoa() function.
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ go โ€บ converting a string to an integer in go
Converting a string to an integer in Go | Sentry
December 15, 2024 - Note: Although the above example uses base 16 and bit size 32, ParseInt still returns a 64-bit integer. If you want to convert a string to another numerical type, you can use the ParseFloat, ParseUint, or ParseComplex functions, also from the strconv package.
๐ŸŒ
YourBasic
yourbasic.org โ€บ golang โ€บ convert-int-to-string
Convert between int, int64 and string ยท YourBasic Go
The fmt.Sprintf function is a useful general tool for converting data to string: s := fmt.Sprintf("%+8d", 97) // s == " +97" (width 8, right justify, always show sign) See this fmt cheat sheet for more about formatting integers and other types of data with the fmt package. Package strconv ยท golang.org ยท
๐ŸŒ
Golang.cafe
golang.cafe โ€บ blog โ€บ golang-int-to-string-conversion-example
Golang Int To String Conversion Example | Golang.cafe
April 27, 2022 - Go (Golang) provides string and integer conversion directly from a package coming from the standard library - strconv. In order to convert an integer value to string in Golang we can use the FormatInt function from the strconv package.
Find elsewhere
๐ŸŒ
ZetCode
zetcode.com โ€บ golang โ€บ inttostring
Converting Integers to Strings in Go
In Go, we can perform the int to string conversion with the strconv.FormatInt, strconv.Itoa, or fmt.Sprintf functions.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-convert-an-int-to-a-string-in-golang
How to convert an int to a string in Golang
An integer can be converted to a string in Golang using the Itoa function within the strconv library.
Top answer
1 of 6
661

For example strconv.Atoi.

Code:

package main

import (
    "fmt"
    "strconv"
)

func main() {
    s := "123"

    // string to int
    i, err := strconv.Atoi(s)
    if err != nil {
        // ... handle error
        panic(err)
    }

    fmt.Println(s, i)
}
2 of 6
160

Converting Simple strings

The easiest way is to use the strconv.Atoi() function.

Note that there are many other ways. For example fmt.Sscan() and strconv.ParseInt() which give greater flexibility as you can specify the base and bitsize for example. Also as noted in the documentation of strconv.Atoi():

Atoi is equivalent to ParseInt(s, 10, 0), converted to type int.

Here's an example using the mentioned functions (try it on the Go Playground):

flag.Parse()
s := flag.Arg(0)

if i, err := strconv.Atoi(s); err == nil {
    fmt.Printf("i=%d, type: %T\n", i, i)
}

if i, err := strconv.ParseInt(s, 10, 64); err == nil {
    fmt.Printf("i=%d, type: %T\n", i, i)
}

var i int
if _, err := fmt.Sscan(s, &i); err == nil {
    fmt.Printf("i=%d, type: %T\n", i, i)
}

Output (if called with argument "123"):

i=123, type: int
i=123, type: int64
i=123, type: int

Parsing Custom strings

There is also a handy fmt.Sscanf() which gives even greater flexibility as with the format string you can specify the number format (like width, base etc.) along with additional extra characters in the input string.

This is great for parsing custom strings holding a number. For example if your input is provided in a form of "id:00123" where you have a prefix "id:" and the number is fixed 5 digits, padded with zeros if shorter, this is very easily parsable like this:

s := "id:00123"

var i int
if _, err := fmt.Sscanf(s, "id:%5d", &i); err == nil {
    fmt.Println(i) // Outputs 123
}
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ go language โ€บ different-ways-to-convert-an-integer-variable-to-string-in-golang
Different Ways to Convert an Integer Variable to String in Golang - GeeksforGeeks
April 28, 2025 - It is similar to FormatInt but the difference is that uint64 is the type of integer value. ... Example : Convert an integer variable into String using strconv.FormatUint() function.
๐ŸŒ
GoLinuxCloud
golinuxcloud.com โ€บ home โ€บ golang convert int to string [100% working]
Golang convert INT to STRING [100% Working] | GoLinuxCloud
November 10, 2023 - In this example, we convert the integer 42 to the string "42" using strconv.Itoa and print the result ... strconv.FormatInt is a function provided by the strconv package in Golang to convert an integer to a string while allowing the flexibility ...
๐ŸŒ
Hyno
hyno.co โ€บ blog โ€บ converting-an-integer-to-a-string-in-golang-a-comprehensive-guide.html
How to Convert an Integer to a String in Golang
The strconv package in Golang offers a convenient function called Itoa(). It converts an integer to its corresponding string representation.
๐ŸŒ
DEV Community
dev.to โ€บ emilossola โ€บ converting-integer-to-string-in-golang-nn6
Converting Integer to String in Golang - DEV Community
June 27, 2023 - If an error occurs, it is handled by printing an error message. Otherwise, the converted integer is printed to the console. In Golang, we can format an integer to a string based on the desired base value using the strconv package.
๐ŸŒ
Go Language Tutorial
golangtutorial.dev โ€บ tips โ€บ convert-int-to-string
How to Convert an int32 & int64 to string in Go
November 5, 2020 - Explore topic categories and find resources across Automotive, Finance, Health, Shopping, Travel, and more.
๐ŸŒ
Boldly Go
boldlygo.tech โ€บ archive โ€บ 2024-03-13-converting-integers-to-strings
Converting integers to strings - Boldly Go
Converting a slice of runes to a string type yields a string that is the concatenation of the individual rune values converted to strings. string([]rune{0x767d, 0x9d6c, 0x7fd4}) // "\u767d\u9d6c\u7fd4" == "็™ฝ้ตฌ็ฟ”" string([]rune{}) // "" string([]rune(nil)) // "" type runes []rune string(runes{0x767d, 0x9d6c, 0x7fd4}) // "\u767d\u9d6c\u7fd4" == "็™ฝ้ตฌ็ฟ”" type myRune rune string([]myRune{0x266b, 0x266c}) // "\u266b\u266c" == "โ™ซโ™ฌ" myString([]myRune{0x1f30e}) // "\U0001f30e" == "๐ŸŒŽ" I think this one is pretty intuitive.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ how-to-convert-data-types-in-go
How To Convert Data Types in Go | DigitalOcean
May 9, 2019 - You can convert numbers to strings by using the strconv.Itoa method from the strconv package in the Go standard libary. If you pass either a number or a variable into the parentheses of the method, that numeric value will be converted into a string value.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ golang-program-to-convert-int-type-variables-to-string
Golang Program to convert int type variables to String
November 22, 2022 - Now use Sprintf() function to convert the integer type value to string and pass the integer number as an argument to it. Store the output in a separate variable here we have named it as result. Print the data type of the result variable along with the value it possesses on the screen using ...
๐ŸŒ
gosamples
gosamples.dev โ€บ tutorials โ€บ convert int to string in go
๐Ÿ”ข Convert int to string in Go
July 23, 2021 - Use strconv.FormatInt function to convert an integer variable to a string in Go.