[Golang] reflect all
This post is about how to use reflect feature to implement as much as you want to do with Golang. Here are some cases: 1. How to get all the fields’ name of an object? 1type A struct{ 2 Foo string 3 Bar int64 4} 5 6func main() { 7 a := &A{Foo: "afoo"} 8 val := reflect.ValueOf(a).Elem() 9 for i:=0; i<val.NumField();i++{ 10 fmt.Println(val.Type().Field(i).Name) 11 } 12} The output: ...