generator

package
v0.0.0-...-7f42b36 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT, MIT Imports: 11 Imported by: 0

README

generator

This code is stolen from https://github.com/abice/go-enum.

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

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 Offset

func Offset(index int, enumType string, val EnumValue) (strResult string)

func Stringify

func Stringify(e Enum, forceLower bool) (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 Config

type Config struct {
	NoPrefix        bool
	LowercaseLookup bool
	CaseInsensitive bool
	Marshal         bool
	Sql             bool
	Flag            bool
	Names           bool
	LeaveSnakeCase  bool
	Prefix          string
	SqlNullInt      bool
	SqlNullStr      bool
	Ptr             bool
	MustParse       bool
	ForceLower      bool
}

type Enum

type Enum = load.Enum

type EnumValue

type EnumValue = load.EnumValue

type Generator

type Generator struct {
	Version   string
	Revision  string
	BuildDate string
	BuiltBy   string

	Config
	// 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, error)

NewGenerator is a constructor method for creating a new Generator with default templates loaded.

func (*Generator) Emit

func (g *Generator) Emit(pkg string, enums []Enum) ([]byte, error)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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