How to list the fields and methods of a struct, in GoLang dynamically? For eg, I want to get the output as id, name, age, and all the method names.
type Student struct {
id int
name string
age int
}
func (s *Student) setId(i int) {
s.id = i
}
func (s *Student) getId() int {
return s.id
}
func (s *Student) setName(n string) {
s.name = n
}
func (s *Student) getName() string {
return s.name
}
func (s *Student) setAge(a int) {
s.age = a
}
func (s *Student) getAge() int {
return s.age
}
func main() {
st := Student{1,"Jack",22}
fmt.Println(st.getId()," ",st.getName()," ",st.getAge())
}