Documentation ¶
Index ¶
- Variables
- func FindPackagesForType(any interface{}) string
- type Config
- func (c *Config) CreateAll(defs []TypeSpec) error
- func (c *Config) CreateFileFromTemplate(template Template) error
- func (c *Config) FilepathSeparator() string
- func (c *Config) GetAPIPath(base string) string
- func (c *Config) GetAllTemplates() error
- func (c *Config) GetDefaultTypeSpec() TypeSpec
- func (c *Config) Process() error
- func (c *Config) SetDefaults()
- func (c *Config) SetModule()
- func (c *Config) SetupFolders() error
- type DirectoryConfig
- type DirectoryName
- type DiscoveryFunction
- type Field
- type File
- type Rule
- type StructSpec
- type Template
- type TypeSpec
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func FindPackagesForType ¶
func FindPackagesForType(any interface{}) string
Types ¶
type Config ¶
type Config struct { Version string // This is the version we want to use for the generator, this will version the API Structs []string // This is the structs we want to process OutputDir string // This is the output directory Directories DirectoryConfig //FileNameConfig FileNameConfig OutputDirPermissions os.FileMode // This is the permissions we will use for the files we generate APIPath string // This is the API Path. The prefix Separator rune // This is the file separator Auth bool // Are we going to do auth FileName string // This is the filename we want to process DiscoverFunction DiscoveryFunction // This is the function which will be called to get the information from the structs TemplateFolder string // If this is set, we will create TemplateSingleton string // TemplateExtension string // CreateFromTemplate bool Template []Template // These are any custom templates CreateRouter bool // Do we want to create the router. This should only be set to false in specific cases CreateHandler bool // Do we want to create the handler. This should only be set to false in specific cases CreateMiddleware bool // Do we want to create the middleware ( struct validation and auth ). This should only be set to false in specific cases RouterTemplate string HandlerTemplate string ValidationMiddlewareTemplate string AuthMiddlewareTemplate string PresenterTemplate string OverrideFiles bool // If we write the files to disk, and a file already exists, do we want to override the current files contents WriteToDisk bool // Will we write the files to disk }
func (*Config) CreateAll ¶
CreateAll will create everything needed for the templates and generate the templates
func (*Config) CreateFileFromTemplate ¶
func (*Config) FilepathSeparator ¶
FilepathSeparator will return the file path separator, it will generally return the filepath.Separator
func (*Config) GetAPIPath ¶
func (*Config) GetAllTemplates ¶
GetAllTemplates This will recursively read all files and folders in `Config.TemplateFolder` adding all the files to `Config.Template` The file content will be the `Template.Content` file name will be `Template.NameFormat` with `%s.` as a prefix the file path will be the OutPath with `Config.TemplateFolder` being stripped from the path and replaced with `.`
func (*Config) GetDefaultTypeSpec ¶
func (*Config) SetupFolders ¶
SetupFolders will create all the folders required for the packages
type DirectoryConfig ¶
type DirectoryName ¶
type DirectoryName int
type Field ¶
type Field struct { Field *ast.Field Rules []Rule Name string // PascalCase APIName string // snake_case VarName string // camelCase Type string // We may want to change this to a token.Token PrimaryKey bool Ignore bool // Do we ignore this field Tag reflect.StructTag // We want to work with the tags }
type Rule ¶
type Rule struct { }
Rule I am not sure how to structure this yet The idea is to hold any rules
type StructSpec ¶
type TypeSpec ¶
type TypeSpec struct { Backtick string TypeSpec *ast.StructType // internal TypeSpec Fields []Field // These are all the fields Ignored bool Version string APIPath string PrimaryKeys []Field // These are all the Primary Keys PrimaryKeyCount int Struct StructSpec Module string // This is the application module. Package string // This is the package IntermediaryPath string // This is the path between the Module and the Package Path Auth bool }
func GoDocReader ¶
func (*TypeSpec) Generate ¶
Generate will generate the File for the TypeSpec using the template passed. This will generate both the handler and the router It may also generate specific middleware, auth, validation
func (*TypeSpec) GenerateUsingFile ¶
GenerateUsingFile will generate the File for the TypeSpec using the template passed. This will generate both the handler and the router It may also generate specific middleware, auth, validation
func (*TypeSpec) GetAllFiles ¶
GetAllFiles will generate and return all the required `File` for the TypeSpec This will generate the handler and the router, it may also generate specific middleware, auth, validation. This will not write the files