Featured image of post go 语言中类型转换

go 语言中类型转换

string to int

1
2
string转成int:
int, err := strconv.Atoi(string)
1
2
string转成int64:
int64, err := strconv.ParseInt(string, 10, 64)

string to uint

1
2
string转成uint64:
int64, err := strconv.ParseUint(string, 10, 64)

int to string

1
2
int转成string:
string := strconv.Itoa(int)
1
2
int64转成string:
string := strconv.FormatInt(int64,10)

uint to string

1
2
int64转成string:
string := strconv.FormatUint(int64,10)