Get the names of structures that implement an interface, or inherit a structure
After reflect
doing some research on the docs , I don't think this is possible. This is not how go is reflected: the interface mechanism is not declarative (but instead of duck), there is no such list.
However, you might be in luck with a package ast
to parse your project, get a list of types and check for the presence or absence of an interface, then write some code to give you the snippet specified. This will add a step to compilation, but can work like a charm.
source to share
AFAIK, you cannot do this with reflect
, since the packages look out of scope reflect
.
You can do it the same way Godoc static analysis works. That is, using code.google.com/p/go.tools/go/types
to parse the source code of the package and get the type information.
source to share