golang的fmt包实现了格式化I/O函数: package main import "fmt" type Human struct { Name string } func main() { //普通占位符 var people = Human{Name: "咸鱼兆"} // %+v 添加字段名,输出相应值的默认格式 fmt.Printf("%+v\n", people) //相应值用go语法形式输出 fmt.Printf("%#v…
package main import ( "fmt" ) func main() { var a byte = 255 // byte = uint8 rune = int32 fmt.Printf("%v:%T\n", a, a) // 255:uint8 var b int = 380 // 不足位数前面补0 fmt.Printf("%05d:%T\n", b, b) // 00380:int fmt.Printf("%010d:…