Documentation
¶
Index ¶
- func Mapify(e Enum) (ret string, err error)
- func Namify(e Enum) (ret string, err error)
- func Offset(index int, enumType string, val EnumValue) (strResult string)
- func ParseAliases(aliases []string) error
- func Stringify(e Enum, forceLower bool) (ret string, err error)
- func Unmapify(e Enum, lowercase bool) (ret string, err error)
- func UnmapifyStringEnum(e Enum, lowercase bool) (ret string, err error)
- type Enum
- type EnumValue
- type Generator
- func (g *Generator) Generate(f *ast.File) ([]byte, error)
- func (g *Generator) GenerateFromFile(inputFile string) ([]byte, error)
- func (g *Generator) WithBuildTags(tags ...string) *Generator
- func (g *Generator) WithCaseInsensitiveParse() *Generator
- func (g *Generator) WithFlag() *Generator
- func (g *Generator) WithForceLower() *Generator
- func (g *Generator) WithLowercaseVariant() *Generator
- func (g *Generator) WithMarshal() *Generator
- func (g *Generator) WithMustParse() *Generator
- func (g *Generator) WithNames() *Generator
- func (g *Generator) WithNoComments() *Generator
- func (g *Generator) WithNoPrefix() *Generator
- func (g *Generator) WithPrefix(prefix string) *Generator
- func (g *Generator) WithPtr() *Generator
- func (g *Generator) WithSQLDriver() *Generator
- func (g *Generator) WithSQLInt() *Generator
- func (g *Generator) WithSQLNullInt() *Generator
- func (g *Generator) WithSQLNullStr() *Generator
- func (g *Generator) WithTemplates(filenames ...string) *Generator
- func (g *Generator) WithValues() *Generator
- func (g *Generator) WithoutSnakeToCamel() *Generator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAliases ¶
ParseAliases is used to add aliases to replace during name sanitization.
func Stringify ¶
Stringify returns a string that is all of the enum value names concatenated without a separator
Types ¶
type EnumValue ¶
type EnumValue struct { RawName string Name string PrefixedName string ValueStr string ValueInt interface{} Comment string }
EnumValue holds the individual data for each enum value within the found enum.
type Generator ¶
type Generator struct { Version string Revision string BuildDate string BuiltBy string // contains filtered or unexported fields }
Generator is responsible for generating validation files for the given in a go source file.
func NewGenerator ¶
func NewGenerator() *Generator
NewGenerator is a constructor method for creating a new Generator with default templates loaded.
func (*Generator) Generate ¶
Generate does the heavy lifting for the code generation starting from the parsed AST file.
func (*Generator) GenerateFromFile ¶
GenerateFromFile is responsible for orchestrating the Code generation. It results in a byte array that can be written to any file desired. It has already had goimports run on the code before being returned.
func (*Generator) WithBuildTags ¶
WithBuildTags will add build tags to the generated file.
func (*Generator) WithCaseInsensitiveParse ¶
WithLowercaseVariant is used to change the enum const values generated to not have the enum on them.
func (*Generator) WithForceLower ¶
WithForceLower is used to force enums names to lower case while keeping variable names the same.
func (*Generator) WithLowercaseVariant ¶
WithLowercaseVariant is used to change the enum const values generated to not have the enum on them.
func (*Generator) WithMarshal ¶
WithMarshal is used to add marshalling to the enum
func (*Generator) WithMustParse ¶
WithMustParse is used to add a method `MustParse` that will panic on failure.
func (*Generator) WithNoComments ¶
WithNoComments is used to remove auto generated comments from the enum.
func (*Generator) WithNoPrefix ¶
WithNoPrefix is used to change the enum const values generated to not have the enum on them.
func (*Generator) WithPrefix ¶
WithPrefix is used to add a custom prefix to the enum constants
func (*Generator) WithPtr ¶
WithPtr adds a way to get a pointer value straight from the const value.
func (*Generator) WithSQLDriver ¶
WithSQLDriver is used to add marshalling to the enum
func (*Generator) WithSQLInt ¶
WithSQLInt is used to signal a string to be stored as an int.
func (*Generator) WithSQLNullInt ¶
WithSQLNullInt is used to add a null int option for SQL interactions.
func (*Generator) WithSQLNullStr ¶
WithSQLNullStr is used to add a null string option for SQL interactions.
func (*Generator) WithTemplates ¶
WithTemplates is used to provide the filenames of additional templates.
func (*Generator) WithValues ¶
WithValues is used to add Values methods to the enum
func (*Generator) WithoutSnakeToCamel ¶
WithoutSnakeToCamel is used to add flag methods to the enum