Standard library / strconv

strconv.Itoa()

Returns the base-10 string representation of an int, including a minus sign for negative values. Expected stdout: '-42\n'.

Formal Syntax & Structure

go syntaxgo
func Itoa(i int) string

Parameters & Attributes

NameTypeDescription
iintInteger value to encode.

Return Value

string

Encoded representation.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strconv")
func main() {  fmt.Println(strconv.Itoa(-42))}
Go Reference