Golan 类型转换
-
字符串转[]byte
val := []byte("string") // [115 116 114 105 110 103]
-
[]byte转字符串
byte := []byte{98, 108, 97} str := string(byte) //bla
-
int 转int64
num := int64(1)
-
int64转int
num := int(1)
-
int转float32
num := float32(1)
-
string 转 int
num, err := strconv.Atoi("1234345")
-
string转 int64
int64, err := strconv.ParseInt(string, 10, 64)
-
int转 string
string:=strconv.Itoa(int)
-
int64转 string
string:=strconv.FormatInt(int64,10)