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. This library supports conversions to and from string representations to various other data types.

The code snippet below shows how to convert an int to a string using the Itoa function.

package main
import "fmt"
import "strconv"
import "reflect" // The reflect library is used to obtain the datatype of an object.
func main() {
num1:= 10
fmt.Println(num1, reflect.TypeOf(num1))
str:= strconv.Itoa(num1)
fmt.Println(str, reflect.TypeOf(str))
}
New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved