strconv

数字转字符串

package main

import "strconv"

func main () {
  s := strconv.Itoa(-32)
}

字符串转数字

int
package main

import "strconv"

func main () {
  i, err := strconv.Atoi("-32")

  if err != nil {
    ...
  }
}

当然,也要注意长度,其中有一句话

The parse functions return the widest type (float64, int64, and uint64), but if the size argument specifies a narrower width the result can be > converted to that narrower type without data loss:

大意是说在转换时,如果类型设置不对,超出部分的数据将会丢失,毕竟Go是强类型语言