setter

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Description = "make a Receiver.SetXXX function"
View Source
var Flags = []cli.Flag{

	cli.StringFlag{
		Name:  "type,t",
		Usage: "the `TYPE` to setter input",
	},
	cli.StringFlag{
		Name:  "receiver,r",
		Usage: "the `RECEIVER` of the setter",
	},
	cli.StringFlag{
		Name:  "target",
		Usage: "the `TARGET` of the setter",
	},
	cli.StringFlag{
		Name:  "name,n",
		Usage: "the function `NAME`",
		Value: "Set",
	},
	cli.BoolFlag{
		Name:  "withmap,m",
		Usage: "with a map[string]interface{} return",
	},
	cli.BoolFlag{
		Name:  "withold,j",
		Usage: "a map[string]interface{} with old values will return",
	},
	cli.BoolFlag{
		Name:  "checkdiff,d",
		Usage: "check if different with origin value",
	},
	cli.StringFlag{
		Name:  "maptag",
		Usage: "determin the update/old map's key by tag",
	},
	cli.StringFlag{
		Name:  "output,o",
		Usage: "output to `FILE`",
	},
	cli.StringSliceFlag{
		Name:  "import,i",
		Usage: "the requried imports",
	},
	cli.StringSliceFlag{
		Name:  "assign,a",
		Usage: "the exists covnert functions",
	},
	cli.StringFlag{
		Name:  "tag,g",
		Usage: "the tag name",
		Value: "setter",
	},
}
View Source
var Usage = "generate  setter function"

Functions

func Action

func Action(c *cli.Context) error

Types

type AssignConfig

type AssignConfig struct {
	Source string
	Target string
	Assign string
	Check  string
}

type Config

type Config struct {
	Type       string
	Receiver   string
	Target     string
	Name       string
	Withmap    bool
	WithOldMap bool
	CheckDiff  bool
	Output     string
	MapTag     string
	Imports    map[string]string
	Assigns    []*AssignConfig
}

type CustomAssign

type CustomAssign struct {
	Source parser.Type
	Target parser.Type
	Assign parser.Type
	Check  string
}

type Generator

type Generator struct {
	generator.Generator

	TagName    string
	Type       parser.Type
	Receiver   parser.Type
	FuncType   parser.Type
	Withmap    bool
	WithOldMap bool
	CheckDiff  bool
	Reverse    bool
	Assigns    []*CustomAssign
	MapTag     string
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator() *Generator

func (*Generator) AssignerFunc

func (g *Generator) AssignerFunc(field *builder.Field) func(builder.Builder, *builder.Variable, ast.Expr)

func (*Generator) Generate

func (g *Generator) Generate(config *Config) error

func (*Generator) GetCallFunc

func (g *Generator) GetCallFunc(field *builder.Field) parser.Type

func (*Generator) GetFieldMapName

func (g *Generator) GetFieldMapName(field *builder.Field) string

func (*Generator) PrepareAssigns

func (g *Generator) PrepareAssigns(configAssigns []*AssignConfig)

func (*Generator) PrepareTask

func (g *Generator) PrepareTask(config *Config)

func (*Generator) Run

func (g *Generator) Run()

Jump to

Keyboard shortcuts

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