Mutual conversion between strings and various int types in golang go

Go string and int conversion

String to int:

int, err := strconv.Atoi(string)

Convert string to int64:

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

Convert int to string:

string := strconv.Itoa(int)

Convert int64 to string:

string := strconv.FormatInt(int64,10)

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish