go语言把int转为字符串的方法:1、通过“fmt.Println(strconv.Itoa(100))”实现整型转字符串;2、通过“i, _ := strconv.Atoi("100") fmt.Println(i)”实现字符串转整型即可。

本文操作环境:windows10系统、Go 1.11.2、thinkpad t480电脑。
go语言如何把int转为字符串?
整形转字符串
fmt.Println(strconv.Itoa(100))
该方法的源码是:
// Itoa is shorthand for FormatInt(i, 10).
func Itoa(i int) string {
return FormatInt(int64(i), 10)
}可以看出是FormatInt方法的简单实现。
字符串转整形
i, _ := strconv.Atoi("100")
fmt.Println(i)