下面总结了go中常用的转换
#string到intint,err:=strconv.Atoi(string)
#string到int64
int64, err := strconv.ParseInt(string, 10, 64)
#int到string
string:=strconv.Itoa(int)
#int64到string
string:=strconv.FormatInt(int64,10)
#string转float
s := "3.1415926535"v1, err := strconv.ParseFloat(v, 32)v2, err := strconv.ParseFloat(v, 64)
#float转string
v := 3.1415926535s1 := strconv.FormatFloat(v, 'E', -1, 32) //float32s2 := strconv.FormatFloat(v, 'E', -1, 64) //float64
#float截取小数点的位数
func Decimal(value float64) float64 { value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64) return value}
#判断map中的值是否存在
if _, ok := map[key]; ok {//存在}
#go中字符串的截取
res := strings.Split("heng,wowo", ",")
#go中数组转成字符串
proString := strings.Replace(strings.Trim(fmt.Sprint(ress), "[]"), " ", ",", -1)
#go中截取最后一位的字符串
pString = strings.Trim(pString, ",")
#go中计算字符串的长度
len([]rune(teacherInfoMap.Name))