类型转换
数值类型
int32Value := (int32)int64Value
int64Value := (int64)int32Value
float32Value := (float32)int32Value
int32Value := (int32)float32Value数值类型与string
str, err := strconv.Itoa(intValue) // int to str
str := strconv.FormatInt(int64Value, 10) // int64 to str, 十进制
str := strconv.FormatUint(uint64Value, 10) // uint64 to str, 十进制intValue, err := strconv.Atoi(str) // str to int
int64Value, err := strconv.ParseInt(str, 10, 64) // str to int64, 10 base, 64 bits
int64Value, err := strconv.ParseInt(str, 10, 32) // str to int64, 10 base, 32 bits空接口类型
Reference
Last updated