pkg

package
v0.0.0-...-b82eb32 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFieldName

func ExtractFieldName(expr ast.Expr) string

ExtractFieldName extracts the field name from an ast.Expr using reflection

Types

type Config

type Config struct {
	GoPath       string                  `yaml:"go_path"`
	TemplatePath string                  `yaml:"template_path"`
	Name         string                  `yaml:"name"`
	OutputPath   string                  `yaml:"output_path"`
	RemoveFields RemoveFieldsTransformer `yaml:"remove_fields"`
}

type Field

type Field struct {
	SourceName Name
	DestName   Name
	Counter    int
	SourceType string
	DestType   string
	Tags       []map[string]string
	Comment    string
}

type FieldTypeAndNameTransformer

type FieldTypeAndNameTransformer struct{}

func (*FieldTypeAndNameTransformer) Transform

type Name

type Name string

func (*Name) Exported

func (fn *Name) Exported() string

func (*Name) SnakeCase

func (fn *Name) SnakeCase() string

func (*Name) Unexported

func (fn *Name) Unexported() string

type RemoveFieldsTransformer

type RemoveFieldsTransformer struct {
	Enable bool     `yaml:"enable"`
	Fields []string `yaml:"fields"`
}

func (*RemoveFieldsTransformer) Transform

type StructConfig

type StructConfig struct {
	Values map[string]string
	Flags  []string
}

type TemplateContext

type TemplateContext struct {
	TemplateName string
	SourceFile   string
	StructName   Name
	Fields       []Field
	Comments     []string
	Config       StructConfig
}

type Templater

type Templater struct {
	Transformers map[string]TransformerFn
	// contains filtered or unexported fields
}

func NewTemplater

func NewTemplater(configs []Config) *Templater

func NewTemplaterFromPath

func NewTemplaterFromPath(path string) (*Templater, error)

func (*Templater) AddTransformer

func (t *Templater) AddTransformer(name string, fn TransformerFn)

func (*Templater) GenerateFiles

func (t *Templater) GenerateFiles() error

func (*Templater) RunTransformers

func (t *Templater) RunTransformers()

type TransformerFn

type TransformerFn func(ctx *TemplateContext) error

Jump to

Keyboard shortcuts

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