Golang strconv.Itoa() function example

package strconv

Golang strconv.Itoa() function usage example.

 package main

 import (
  "fmt"
  "strconv"
 )

 func main() {

  age := 12

  // will NOT display properly
  fmt.Println(string(age))

  // convert int to string
  agestr := strconv.Itoa(age)

  // will display properly now
  fmt.Println(agestr)

 }

Reference :

http://golang.org/pkg/strconv/#Itoa

Advertisement