generator

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

BuildSteps that'll used for generation.

Functions

func Generate

func Generate(pattern string, mapping []comments.Converter, config Config) (*jen.File, error)

Generate generates a jen.File containing converters.

func ParseMethod

func ParseMethod(method *types.Func, opts ...ParseOpt) (*builder.MethodDefinition, error)

Types

type Config

type Config struct {
	Name          string
	PackagePath   string
	ExtendMethods []string
	WorkingDir    string
}

Config the generate config.

type ParseExtendOptions

type ParseExtendOptions struct {
	// PkgPath where the extend methods are located. If it is empty, the package is same as the
	// ConverterInterface package and ConverterScope should be used for the lookup.
	PkgPath string
	// Scope of the ConverterInterface.
	ConverterScope *types.Scope
	// ConverterInterface to use - can be nil if its use is not allowed.
	ConverterInterface types.Type
	// NamePattern is the regexp pattern to search for within the PkgPath above or
	// (if PkgPath is empty) within the Scope.
	NamePattern *regexp.Regexp
}

ParseExtendOptions holds extend method options.

type ParseOpt

type ParseOpt func(opt *ParseOption)

func UseConverterInter

func UseConverterInter(inter types.Type) ParseOpt

func UseExplicit

func UseExplicit(e bool) ParseOpt

func UseQual

func UseQual(q string) ParseOpt

type ParseOption

type ParseOption struct {
	ConverterInterface types.Type
	Qual               string
	Explicit           bool
}

Jump to

Keyboard shortcuts

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