config

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnumActionPanic  = "@panic"
	EnumActionError  = "@error"
	EnumActionIgnore = "@ignore"
)

Variables

View Source
var DefaultConfigInterface = ConverterConfig{
	OutputFile:        "./generated/generated.go",
	OutputPackageName: "generated",
	Common:            Common{Enum: enum.Config{Enabled: true}},
	OutputFormat:      FormatStruct,
}
View Source
var DefaultConfigVariables = ConverterConfig{
	OutputFormat: FormatVariable,
	Common:       Common{Enum: enum.Config{Enabled: true}},
}

Functions

func IsEnumAction added in v1.4.0

func IsEnumAction(s string) bool

Types

type Common

type Common struct {
	FieldSettings                      []string
	WrapErrors                         bool
	WrapErrorsUsing                    string
	IgnoreUnexported                   bool
	MatchIgnoreCase                    bool
	IgnoreMissing                      bool
	SkipCopySameType                   bool
	UseZeroValueOnPointerInconsistency bool
	UseUnderlyingTypeMethods           bool
	Enum                               enum.Config
}

type ConfiguredTransformer added in v1.4.0

type ConfiguredTransformer struct {
	Name        string
	Transformer enum.Transformer
	Config      string
}

type Converter

type Converter struct {
	ConverterConfig
	Package  string
	FileName string

	Methods map[string]*Method

	Location string
	// contains filtered or unexported fields
}

func Parse

func Parse(raw *Raw) ([]*Converter, error)

func (*Converter) IDString added in v1.5.0

func (c *Converter) IDString() string

type ConverterConfig

type ConverterConfig struct {
	Common
	Name              string
	OutputFile        string
	OutputPackagePath string
	OutputPackageName string
	OutputFormat      Format
	Extend            []*method.Definition
	Comments          []string
}

func (*ConverterConfig) PackageID added in v1.2.0

func (conf *ConverterConfig) PackageID() string

type EnumMapping added in v1.4.0

type EnumMapping struct {
	Transformers []ConfiguredTransformer
	Map          map[string]string
}

type FieldMapping

type FieldMapping struct {
	Source   string
	Function *method.Definition
	Ignore   bool
}

type Format added in v1.5.0

type Format string
const (
	FormatStruct   Format = "struct"
	FormatVariable Format = "assign-variable"
	FormatFunction Format = "function"
)

type Method

type Method struct {
	*method.Definition
	Common

	Constructor *method.Definition
	AutoMap     []string
	Fields      map[string]*FieldMapping
	EnumMapping *EnumMapping

	RawFieldSettings []string

	Location string
}

func (*Method) Field

func (m *Method) Field(targetName string) *FieldMapping

type Raw

type Raw struct {
	Converters []RawConverter
	Global     RawLines

	WorkDir              string
	BuildTags            string
	OuputBuildConstraint string

	EnumTransformers map[string]enum.Transformer
}

type RawConverter

type RawConverter struct {
	PackagePath   string
	PackageName   string
	InterfaceName string
	Converter     RawLines
	Methods       map[string]RawLines
	FileName      string
}

type RawLines

type RawLines struct {
	Location string
	Lines    []string
}

Jump to

Keyboard shortcuts

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