Documentation ¶
Index ¶
- type AutoGeneratedRegistryWriter
- type AutoRegistryGenerator
- type Registry
- type RegistryFactory
- type RegistryInterface
- type RegistryStruct
- type TypeRegistry
- func (r *TypeRegistry) Add(registry Registry)
- func (r *TypeRegistry) FindFactoryTypes(name string) []interface{}
- func (r *TypeRegistry) FindInterfaceType(name string) interface{}
- func (r *TypeRegistry) FindInterfaceTypeByType(objType reflect.Type) interface{}
- func (r *TypeRegistry) FindStructType(name string) interface{}
- func (r *TypeRegistry) FindStructTypeByType(objType reflect.Type) interface{}
- func (r *TypeRegistry) FindStructTypesByInterfaceType(interfaceName string) (structs []interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoGeneratedRegistryWriter ¶
type AutoGeneratedRegistryWriter struct{}
An object responsible for writing packageData structs to a file given the template above.
func (*AutoGeneratedRegistryWriter) WriteAutoGeneratedDataToFile ¶
func (*AutoGeneratedRegistryWriter) WriteAutoGeneratedDataToFile(packageDataList []packageData, filePath string)
Write the results of []packageData to a readable to file. Could've used the AST for this, but I'm lazy...
func (*AutoGeneratedRegistryWriter) WriteDefaultFile ¶
func (*AutoGeneratedRegistryWriter) WriteDefaultFile(filePath string)
Write the contents of defaultFile to the file.
type AutoRegistryGenerator ¶
type AutoRegistryGenerator struct {
// contains filtered or unexported fields
}
An object capable of immense wizardry.
func NewAutoRegistryGenerator ¶
func NewAutoRegistryGenerator(registryWriter AutoGeneratedRegistryWriter) AutoRegistryGenerator
Initialise a new instance of AutoRegistryGenerator.
func (*AutoRegistryGenerator) Generate ¶
func (g *AutoRegistryGenerator) Generate(file string, dirPath string, ignoreDirs ...string)
Generate a registry of all types within the application, given a root directory to recurse.
The file argument is the file to write the registry to. The dirPath option is the root directory to start recursing through. The ignoreDirs option is to pass in a list of directories to ignore such as vendor/.
func (*AutoRegistryGenerator) Reset ¶
func (g *AutoRegistryGenerator) Reset(filePath string)
Reset the generated file to defaults.
type Registry ¶
type Registry struct { RegistryStructs []RegistryStruct RegistryFactories []RegistryFactory RegistryInterfaces []RegistryInterface }
type RegistryFactory ¶
type RegistryFactory struct { Name string Implementations []interface{} }
type RegistryInterface ¶
type RegistryInterface RegistryStruct
type RegistryStruct ¶
type RegistryStruct struct { Name string Implementation interface{} }
The types available in the auto-generated registry.
type TypeRegistry ¶
type TypeRegistry struct {
// contains filtered or unexported fields
}
A structRegistry containing all structs, and their package names, in the application.
func New ¶
func New(registries ...Registry) *TypeRegistry
Terrible wizardry. You can pass the registry in created from having run ./bin/gen.
func (*TypeRegistry) Add ¶
func (r *TypeRegistry) Add(registry Registry)
func (*TypeRegistry) FindFactoryTypes ¶
func (r *TypeRegistry) FindFactoryTypes(name string) []interface{}
func (*TypeRegistry) FindInterfaceType ¶
func (r *TypeRegistry) FindInterfaceType(name string) interface{}
func (*TypeRegistry) FindInterfaceTypeByType ¶
func (r *TypeRegistry) FindInterfaceTypeByType(objType reflect.Type) interface{}
Given a reflect value (when recursing around a struct's fields with reflect); find the object already stored.
func (*TypeRegistry) FindStructType ¶
func (r *TypeRegistry) FindStructType(name string) interface{}
func (*TypeRegistry) FindStructTypeByType ¶
func (r *TypeRegistry) FindStructTypeByType(objType reflect.Type) interface{}
Given a reflect value (when recursing around a struct's fields with reflect); find the object already stored.
func (*TypeRegistry) FindStructTypesByInterfaceType ¶
func (r *TypeRegistry) FindStructTypesByInterfaceType(interfaceName string) (structs []interface{})
Given an interface name, if registered, return all struct types that implement it.