1、int转string
#int到string
string := strconv.Itoa(int)
//等价于
string := strconv.FormatInt(int64(int),10)
#int64到string
string := strconv.FormatInt(int64,10)
fmt.Sprintf("%d",num)
2、string 转int
#string到int
int,err := strconv.Atoi(string)
#string到int64
int64, err := strconv.ParseInt(string, 10, 64)
3、string 转 float (32/64)
#string到float64
float,err := strconv.ParseFloat(string,64)
#string到float32
float,err := strconv.ParseFloat(string,32)
4、float 转string
s1 := strconv.FormatFloat(vfloat, ‘f’, -1, 32)//float32
s2 := strconv.FormatFloat(v, f’, -1, 64)//float64
str = fmt.Sprintf("%f",num2)