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 to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved