package main
import (
"fmt"
"reflect"
)
func main() {
x := struct {
Foo string
Bar int
}{"foo", 2}
t := reflect.TypeOf(x)
v := reflect.ValueOf(x)
for i := range make([]struct{}, t.NumField()) {
fmt.Println(t.Field(i).Name, v.FieldByName(t.Field(i).Name).Interface())
}
}