I would like to be able to get all structs. For example, assume we have:
type SomeType struct {
// ..
}
type someType2 struct {
//..
}
Our code.
structs := getAllStructs(srcPath) //gets SomeType and someType2
I have some code which finds all .go files in srcPath and does parser.ParseFile on it.
Is there a way using ast, parser, packages, etc... I can get all structs at once at any scope? What if there is a struct which is not package scoped? How can I get struct declarations also inside the function? Like:
func main() {
type someType3 struct {
//..
}
}