Golan 类型转换

Golan 类型转换

  1. 字符串转[]byte

    val := []byte("string") // [115 116 114 105 110 103]
    
  2. []byte转字符串

    byte := []byte{98, 108, 97}
    str := string(byte) //bla
    
  3. int 转int64

    num := int64(1)
    
  4. int64转int

    num := int(1)
    
  5. int转float32

    num := float32(1)
    
  6. string 转 int

    num, err := strconv.Atoi("1234345")
    
  7. string转 int64

    int64, err := strconv.ParseInt(string, 10, 64)
    
  8. int转 string

    string:=strconv.Itoa(int)
    
  9. int64转 string

    string:=strconv.FormatInt(int64,10)
    

你可能感兴趣的:(Golan 类型转换)