go语言中string(int)会把int当成UTF-8的Unicode值,转换成对应的字符,标准库strconv是专门用来实现基本数据类型和其字符串表示的相互转换。

package main

import (
	"fmt"
	"strconv"
)

func main() {
	// 64位整型
	i := int64(123)

	// 整型转UTF-8字符
	s := string(i)
	fmt.Println(s) // {

	// 整型转字符串
	s1 := strconv.FormatInt(i, 10)
	fmt.Println(s1) // 123
}
package main

import (
	"fmt"
	"strconv"
)

func main() {
	//string到int
	s := "1"
	i, _ := strconv.Atoi(s)
	fmt.Println(i)
	fmt.Printf("%T\r\n", i)

	//string到int64
	s64 := "64"
	i64, _ := strconv.ParseInt(s64, 10, 64)
	fmt.Println(i64)
	fmt.Printf("%T\r\n", i64)

	//int到string
	s = strconv.Itoa(i)
	fmt.Println(s)

	//int64到string
	s64 = strconv.FormatInt(i64, 10)
	fmt.Println(s64)

	//string到float32(float64)
	sfloat := "1.23"
	f32, _ := strconv.ParseFloat(sfloat, 32/64)
	fmt.Println(f32)          // 1.23
	fmt.Printf("%T\r\n", f32) // float64

	//float到string
	sf32 := strconv.FormatFloat(f32, 'E', -1, 32)
	fmt.Println(sf32)
	f64 := float64(100.23456) // 1.23E+00
	sf64 := strconv.FormatFloat(f64, 'E', -1, 64)
	fmt.Println(sf64) // 1.0023456E+02
	// 'b' (-ddddp±ddd,二进制指数)
	// 'e' (-d.dddde±dd,十进制指数)
	// 'E' (-d.ddddE±dd,十进制指数)
	// 'f' (-ddd.dddd,没有指数)
	// 'g' ('e':大指数,'f':其它情况)
	// 'G' ('E':大指数,'f':其它情况)
}

参考

http://doc.golang.ltd/pkg/strconv.htm