package main

import (
	"fmt"
	"strconv"
)

func main() {
	var num1 int = 88
	var num2 int64 = 123
	var str111 string = "456"

	// int -> string
	str1 := strconv.Itoa(num1)
	fmt.Printf("%T:%v\n", str1, str1)  // string:88

	// int64 -> string
	str2 := strconv.FormatInt(num2, 10)  // base: 10代表十进制
	fmt.Printf("%T:%v\n", str2, str2)  // string:123

	// string -> int
	num111, err1 := strconv.Atoi(str111)
	fmt.Printf("%T:%v:%v\n", num111, num111, err1)  // int:456:<nil>

	// string -> int64
	num222, err2 := strconv.ParseInt(str111, 10, 64)
	fmt.Printf("%T:%v:%v\n", num222, num222, err2)  // int64:456:<nil>

	// string -> float64
	num333, err3 := strconv.ParseFloat(str111, 64)
	fmt.Printf("%T:%v:%v\n", num333, num333, err3)  //

	// int -> float32
	num444 := float32(num1)
	fmt.Printf("%T:%v\n", num444, num444)

	// int -> float64
	num555 := float64(num1)
	fmt.Printf("%T:%v\n", num555, num555)

	// float32 -> int16
	num666 := int16(num444)
	fmt.Printf("%T:%v\n", num666, num666)

}