Skip to content

Instantly share code, notes, and snippets.

@sharewind
Created December 19, 2013 06:59
Show Gist options
  • Save sharewind/8035409 to your computer and use it in GitHub Desktop.
Save sharewind/8035409 to your computer and use it in GitHub Desktop.
type T struct {
A int
B string
}
t := T{23, "skidoo"}
s := reflect.ValueOf(&t).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
f := s.Field(i)
fmt.Printf("%d: %s %s = %v\n", i,
typeOfT.Field(i).Name, f.Type(), f.Interface())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment