Home>Article>Backend Development> How to convert int to string in go language
Go language method to convert int to string: 1. Use "fmt.Println(strconv.Itoa(100))" to convert integer to string; 2. Use "i, _ := strconv .Atoi("100") fmt.Println(i)" can be used to convert string to integer.
The operating environment of this article: windows10 system, Go 1.11.2, thinkpad t480 computer.
How to convert int to string in Go language?
Integer to string
fmt.Println(strconv.Itoa(100))
The source code of this method is:
// Itoa is shorthand for FormatInt(i, 10). func Itoa(i int) string { return FormatInt(int64(i), 10) }
It can be seen that it is a simple implementation of the FormatInt method.
Convert string to integer
i, _ := strconv.Atoi("100") fmt.Println(i)
Related recommendations:golang tutorial
The above is the detailed content of How to convert int to string in go language. For more information, please follow other related articles on the PHP Chinese website!