Documentation
¶
Overview ¶
Package generator provides enum code generation functionality.
Index ¶
- Constants
- Variables
- func GetValueName(v *genkit.EnumValue, typeName string) string
- func TrimPrefix(name, prefix string) string
- type GenerateOption
- func (x GenerateOption) IsValid() bool
- func (x GenerateOption) MarshalJSON() ([]byte, error)
- func (x GenerateOption) MarshalText() ([]byte, error)
- func (x *GenerateOption) Scan(src any) error
- func (x GenerateOption) String() string
- func (x *GenerateOption) UnmarshalJSON(data []byte) error
- func (x *GenerateOption) UnmarshalText(data []byte) error
- func (x GenerateOption) Value() (driver.Value, error)
- type Generator
- func (eg *Generator) FindEnums(pkg *genkit.Package) []*genkit.Enum
- func (eg *Generator) GenerateEnum(g *genkit.GeneratedFile, enum *genkit.Enum) error
- func (eg *Generator) Name() string
- func (eg *Generator) ProcessPackage(gen *genkit.Generator, pkg *genkit.Package) error
- func (eg *Generator) Run(gen *genkit.Generator, log *genkit.Logger) error
- func (eg *Generator) WriteHeader(g *genkit.GeneratedFile, pkgName string)
Constants ¶
const ToolName = "enumgen"
ToolName is the name of this tool, used in annotations.
Variables ¶
var GenerateOptionEnums = _GenerateOptionEnums{ // contains filtered or unexported fields }
GenerateOptionEnums is the enum helper for GenerateOption.
Functions ¶
func GetValueName ¶
GetValueName returns the display name for an enum value. It checks for enumgen:@name annotation first, otherwise uses TrimPrefix.
func TrimPrefix ¶
TrimPrefix removes the type name prefix from an enum value name.
Types ¶
type GenerateOption ¶
type GenerateOption int
GenerateOption represents an enum generation option. enumgen:@enum(string, json, text, sql)
const ( // enumgen:@name(string) GenerateOptionString GenerateOption = iota + 1 // enumgen:@name(json) GenerateOptionJSON // enumgen:@name(text) GenerateOptionText // enumgen:@name(sql) GenerateOptionSQL )
func (GenerateOption) IsValid ¶
func (x GenerateOption) IsValid() bool
IsValid reports whether x is a valid GenerateOption.
func (GenerateOption) MarshalJSON ¶
func (x GenerateOption) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (GenerateOption) MarshalText ¶
func (x GenerateOption) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (*GenerateOption) Scan ¶
func (x *GenerateOption) Scan(src any) error
Scan implements sql.Scanner.
func (GenerateOption) String ¶
func (x GenerateOption) String() string
String returns the string representation of GenerateOption.
func (*GenerateOption) UnmarshalJSON ¶
func (x *GenerateOption) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*GenerateOption) UnmarshalText ¶
func (x *GenerateOption) UnmarshalText(data []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type Generator ¶
type Generator struct{}
Generator generates enum helper methods.
func (*Generator) GenerateEnum ¶
GenerateEnum generates helper code for a single enum.
func (*Generator) ProcessPackage ¶
ProcessPackage processes a package and generates enum helpers.
func (*Generator) WriteHeader ¶
func (eg *Generator) WriteHeader(g *genkit.GeneratedFile, pkgName string)
WriteHeader writes the file header.