内容取自于公众号:Go程序员开发 类型转换用于将一种数据类型的变量转换为另外一种类型的变量。 转字符串 布尔值转字符串: package main import ( "fmt" "reflect" "strconv" ) func main() { t := strconv.FormatBool(true) f := strconv.FormatBool(false) fmt.Printf("t is %v , t type is %v\n", t, reflect.TypeOf(t)) fmt.Printf("f is %v , f type is %v\n", f, reflect.TypeOf(f)) } |
|