generator

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2018 License: MIT Imports: 14 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 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
}

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) WithNoPrefix

func (g *Generator) WithNoPrefix() *Generator

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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