Documentation
¶
Index ¶
- Variables
- func RegisterCustomMapper[IN any, OUT any, Fn ConverterFunc[IN, OUT]](customMapperFunc Fn)
- type ConverterFunc
- type FieldOptions
- type FunctionContext
- type Generator
- type GeneratorFunc
- type GoField
- type GoFieldPath
- type GoFunction
- type GoInterface
- type GoKind
- type GoParameter
- type GoType
- type Interface
- type Parser
- type ResolvedMapping
- type TypeGraph
- type TypeMapping
- type TypePair
Constants ¶
This section is empty.
Variables ¶
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 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 (*Generator) AddTypeMapping ¶
func (m *Generator) AddTypeMapping(mapping *TypeMapping)
func (*Generator) GenerateInterface ¶
func (m *Generator) GenerateInterface(in *GoInterface) error
func (*Generator) SetStrictEnums ¶
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.
type GeneratorFunc ¶
type GeneratorFunc func(ctx *FunctionContext, input jen.Code) jen.Code
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 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 MustLookupType ¶
type Interface ¶
type Interface struct {
Name string
Mappers []*TypeMapping
}
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