总结了golang中字符串和各种int类型之间的相互转换方式:

string转成int:

i, err := strconv.Atoi(string)

string转成int64:

i, err := strconv.ParseInt(string, 10, 64)

int转成string:

str := strconv.Itoa(int)

int64转成string:

str := strconv.FormatInt(int64,10)

注意:不能直接用string(int),用于int 转 string。
string() 的作用是生成 int 对应 ascii 码的字符串。

免责声明:本文内容来自简书>作者 : 齐舞647,遵循CC 4.0 BY-SA版权协议,载请附上原文出处链接及本声明。
本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行可。
原文链接:https://www.jianshu.com/p/47df74b34fe0
如有涉及到侵权,请联系,将立即予以删除处理。
在此特别鸣谢:简书博主>齐舞647的创作。
本文发布已获原作者授权转载。