Convert string, int, int64 to each other in Golang

Just use the official strconv package:

#string to int  
int,err:=strconv.Atoi(string)  
#string to int64  
int64, err := strconv.ParseInt(string, 10, 64)  
#int to string  
string:=strconv.Itoa(int)  
#int64 to string  
string:=strconv.FormatInt(int64,10)  

Convert between the same type, such as int64 to int, directly int (int64);



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324758798&siteId=291194637