Skip to content

Instantly share code, notes, and snippets.

@barryz
Last active February 12, 2018 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryz/1505b0142763ae2d90c825a224d1ddfd to your computer and use it in GitHub Desktop.
Save barryz/1505b0142763ae2d90c825a224d1ddfd to your computer and use it in GitHub Desktop.
Go tip for print struct
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