Using reflect, I'm trying to access the fields of a Parent struct from within a function implemented on the "Base" struct, like this:
type Base struct {
X int
}
type Extra struct {
Base
Y int
Z int
}
func (b *Base) Hitme() {
// Want to access the list of "Extra" fields here
}
The b
value only allows me to access the "X" value, not "Y" or "Z".
Here's a compilable example on playground: https://play.golang.org/p/fX0bX_x7FzC
Aucun commentaire:
Enregistrer un commentaire