mapper

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StringType        = getGoType(types.Typ[types.String])
	IsZeroerInterface = types.NewInterfaceType([]*types.Func{
		types.NewFunc(token.NoPos, types.NewPackage("", ""), "IsZero",
			types.NewSignatureType(nil, nil, nil, nil,
				types.NewTuple(types.NewVar(token.NoPos, types.NewPackage("", ""), "", types.Typ[types.Bool])),
				false),
		),
	}, nil)
)

Functions

func RegisterCustomMapper

func RegisterCustomMapper[IN any, OUT any, Fn ConverterFunc[IN, OUT]](customMapperFunc Fn)

RegisterCustomMapper allows users to register their own custom mapping functions. The customMapperFunc must be a function with one input parameter and either one return value or two return values (where the second is an error). It panics if either type cannot be loaded from the module the generator runs in.

Types

type ConverterFunc

type ConverterFunc[IN any, OUT any] interface {
	~func(IN) OUT | ~func(IN) (OUT, error)
}

type FieldOptions

type FieldOptions struct {
	// contains filtered or unexported fields
}

type FunctionContext

type FunctionContext struct {
	// contains filtered or unexported fields
}

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(pkg string, dir string) *Generator

func (*Generator) AddTypeMapping

func (m *Generator) AddTypeMapping(mapping *TypeMapping)

func (*Generator) GenerateInterface

func (m *Generator) GenerateInterface(in *GoInterface) error

func (*Generator) Render

func (m *Generator) Render() error

func (*Generator) SetSrcDir

func (m *Generator) SetSrcDir(dir string)

func (*Generator) SetStrictEnums

func (m *Generator) SetStrictEnums(strict bool)

SetStrictEnums turns enum compatibility problems into errors. By default they are only logged, since two enums may legitimately diverge on values that never reach the mapper.

func (*Generator) String

func (m *Generator) String() (string, error)

type GeneratorFunc

type GeneratorFunc func(ctx *FunctionContext, input jen.Code) jen.Code

type GoField

type GoField struct {
	// contains filtered or unexported fields
}

type GoFieldPath

type GoFieldPath []*GoField

type GoFunction

type GoFunction struct {
	// contains filtered or unexported fields
}

type GoInterface

type GoInterface struct {
	Name    string
	Pkg     string
	Type    *types.Interface
	Methods []*GoFunction
	// contains filtered or unexported fields
}

type GoKind

type GoKind int
const (
	InvalidKind GoKind = iota
	BasicKind
	StructKind
	SliceKind
	PointerKind
	MapKind
	ArrayKind
)

type GoParameter

type GoParameter struct {
	// contains filtered or unexported fields
}

type GoType

type GoType struct {
	Kind GoKind
	Raw  types.Type

	Name     string
	Pkg      string
	TypeName string

	IsProtoEnum bool

	// if Kind is struct
	Fields []*GoField

	// if Kind is SliceKind or PointerKind
	Element *GoType

	// if Kind is MapKind
	Key   *GoType
	Value *GoType

	// if Kind is basic
	BasicInfo types.BasicInfo
}

func LookupType

func LookupType(name string) (*GoType, error)

func MustLookupType

func MustLookupType(name string) *GoType

func (*GoType) String

func (g *GoType) String() string

type Interface

type Interface struct {
	Name    string
	Mappers []*TypeMapping
}

type Parser

type Parser struct{}

func NewParser

func NewParser() *Parser

func (*Parser) Parse

func (p *Parser) Parse(dir string, patterns ...string) ([]*GoInterface, error)

type ResolvedMapping

type ResolvedMapping struct {
	// contains filtered or unexported fields
}

type TypeGraph

type TypeGraph struct {
	// contains filtered or unexported fields
}

func NewTypeGraph

func NewTypeGraph() *TypeGraph

type TypeMapping

type TypeMapping struct {
	// contains filtered or unexported fields
}

func DefaultTypeMappings

func DefaultTypeMappings() []*TypeMapping

type TypePair

type TypePair struct {
	// contains filtered or unexported fields
}

func (TypePair) String

func (t TypePair) String() string

Jump to

Keyboard shortcuts

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