Last active
February 12, 2018 10:07
-
-
Save barryz/1505b0142763ae2d90c825a224d1ddfd to your computer and use it in GitHub Desktop.
Go tip for print struct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Test struct { | |
Name string | |
Age int | |
} | |
func main() { | |
t := &Test{Name: "haha", Age: 11} | |
fmt.Printf("%#v\n", t) // 显示包名 类型名 字段名 字段值 | |
fmt.Printf("%+v\n", t) // 显示 类型名 字段名 字段值 | |
fmt.Printf("%v\n", t) // 显示 字段值 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment