generator

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mapify

func Mapify(e Enum) (ret string, err error)

Mapify returns a map that is all of the indexes for a string value lookup

func Namify added in v0.1.4

func Namify(e Enum) (ret string, err error)

Namify returns a slice that is all of the possible names for an enum in a slice

func Stringify

func Stringify(e Enum) (ret string, err error)

Stringify returns a string that is all of the enum value names concatenated without a separator

func Unmapify

func Unmapify(e Enum, lowercase bool) (ret string, err error)

Unmapify returns a map that is all of the indexes for a string value lookup

Types

type Enum

type Enum struct {
	Name   string
	Prefix string
	Type   string
	Values []EnumValue
}

Enum holds data for a discovered enum in the parsed source

type EnumValue

type EnumValue struct {
	RawName      string
	Name         string
	PrefixedName string
	Value        int
	Comment      string
}

EnumValue holds the individual data for each enum value within the found enum.

type Generator

type Generator struct {
	// 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

func (g *Generator) Generate(f *ast.File) ([]byte, error)

Generate does the heavy lifting for the code generation starting from the parsed AST file.

func (*Generator) GenerateFromFile

func (g *Generator) GenerateFromFile(inputFile string) ([]byte, error)

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) WithFlag added in v0.1.3

func (g *Generator) WithFlag() *Generator

WithFlag is used to add flag methods to the enum

func (*Generator) WithLowercaseVariant

func (g *Generator) WithLowercaseVariant() *Generator

WithLowercaseVariant is used to change the enum const values generated to not have the enum on them.

func (*Generator) WithMarshal

func (g *Generator) WithMarshal() *Generator

WithMarshal is used to add marshalling to the enum

func (*Generator) WithNames added in v0.1.4

func (g *Generator) WithNames() *Generator

WithNames is used to add Names methods to the enum

func (*Generator) WithNoPrefix

func (g *Generator) WithNoPrefix() *Generator

WithNoPrefix is used to change the enum const values generated to not have the enum on them.

func (*Generator) WithSQLDriver added in v0.1.5

func (g *Generator) WithSQLDriver() *Generator

WithSQLDriver is used to add marshalling to the enum

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL