Converting an Int to a String

· 0 word · 0 minutes read

This is a short example on how to convert an integer number into a string. This is a common use case when printing to screen or working with the number as if it was a string. To do this we use the strconv package and the Itoa function.

package main

import (

func main() {
    // Will print Number: 1234
    anInt := 1234
    fmt.Println("Number: " + strconv.Itoa(anInt))
Image of Author Edd Turtle

Author: Edd Turtle

Edd is the Lead Developer at Hoowla, a prop-tech startup, where he spends much of his time working on production-ready Go and PHP code.

See something which isn't right? You can contribute to this page on GitHub or just let us know in the comments below. Thanks for reading!