Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator interface { // Generate generates the enum helpers, as well as test code if desired. If the generation fails, an error is // returned. Generate(spec Spec) ([]byte, []byte, error) }
Generator generates helper code for working with enums.
type Spec ¶
type Spec struct { // Type is the type to generate enum helpers for. Type string // Directory is the source directory for the generation. Directory string // GenerateTests generates test code for the generated enum code. GenerateTests bool // GenerateValidate generates a validation function. GenerateValidate bool // GenerateValues generates a values function. GenerateValues bool // GenerateListType generates a list type. GenerateListType bool // GenerateJSON generates a JSON unmarshaller with validation. GenerateJSON bool }
Spec is the configuration for the Generator.
type TemplateScope ¶
type TemplateScope struct { // Exported is true if the type is exported. Exported bool // Package is the package name for the type. Package string // First is the first letter of the type. First string // LowerFirst is the first letter of the type, lower case. LowerFirst string // Type is the name of the type being generated. Type string // Values is a list of values for the enum. Values []string // ConvertToString is the prefix for converting to string. ConvertToString string // ConverToStringEnd is the suffix for converting to string. ConvertToStringEnd string // RawType is the underlying type. RawType string // Spec is the input spec. Spec Spec // ConvertImports holds a list of imports used for conversion. ConvertImports map[string]struct{} }
TemplateScope is the data for rendering templates.
func (TemplateScope) Imports ¶
func (t TemplateScope) Imports(added ...string) []string
Click to show internal directories.
Click to hide internal directories.