Documentation
¶
Overview ¶
Code generated from Pkl module `gomappergen.mapper`. DO NOT EDIT.
Code generated from Pkl module `gomappergen.mapper`. DO NOT EDIT.
Code generated from Pkl module `gomappergen.mapper`. DO NOT EDIT.
Code generated from Pkl module `gomappergen.mapper`. DO NOT EDIT.
Code generated from Pkl module `gomappergen.mapper`. DO NOT EDIT.
Code generated from Pkl module `gomappergen.mapper`. DO NOT EDIT.
Code generated from Pkl module `gomappergen.mapper`. DO NOT EDIT.
Code generated from Pkl module `gomappergen.mapper`. DO NOT EDIT.
Code generated from Pkl module `gomappergen.mapper`. DO NOT EDIT.
Index ¶
- type BuiltInConverter
- type BuiltInLibraryConverter
- type Converter
- type FieldInterceptor
- type Fields
- type Mapper
- type Package
- type PackageImpl
- func (rcv PackageImpl) GetConstructorName() string
- func (rcv PackageImpl) GetDecorateFunctionName() string
- func (rcv PackageImpl) GetDecoratorInterfaceName() string
- func (rcv PackageImpl) GetDecoratorMode() decoratormode.DecoratorMode
- func (rcv PackageImpl) GetDecoratorNoopName() string
- func (rcv PackageImpl) GetGenerateGoDoc() bool
- func (rcv PackageImpl) GetGenerateSourceFromTarget() bool
- func (rcv PackageImpl) GetGenerateSourceToTarget() bool
- func (rcv PackageImpl) GetImplementationName() string
- func (rcv PackageImpl) GetInterfaceName() string
- func (rcv PackageImpl) GetMode() string
- func (rcv PackageImpl) GetPointer() pointer.Pointer
- func (rcv PackageImpl) GetSourceFromTargetFunctionName() string
- func (rcv PackageImpl) GetSourcePkg() string
- func (rcv PackageImpl) GetSourceToTargetFunctionName() string
- func (rcv PackageImpl) GetStructs() map[string]Struct
- func (rcv PackageImpl) GetTargetPkg() string
- func (rcv PackageImpl) GetUseGetterIfAvailable() bool
- type Struct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuiltInConverter ¶
type BuiltInConverter struct {
EnableIdentical bool `pkl:"enable_identical"`
EnableSlice bool `pkl:"enable_slice"`
EnableTypeToPointer bool `pkl:"enable_type_to_pointer"`
EnablePointerToType bool `pkl:"enable_pointer_to_type"`
EnableNumeric bool `pkl:"enable_numeric"`
EnableFunctions bool `pkl:"enable_functions"`
EnableFunctionsStrict bool `pkl:"enable_functions_strict"`
Library BuiltInLibraryConverter `pkl:"library"`
}
type BuiltInLibraryConverter ¶
type Converter ¶
type Converter struct {
BuiltIn BuiltInConverter `pkl:"built_in"`
Functions *[]string `pkl:"functions"`
Priorities []string `pkl:"priorities"`
}
type FieldInterceptor ¶ added in v0.5.0
type Fields ¶
type Fields struct {
Match string `pkl:"match"`
Map *map[string]string `pkl:"map"`
Target *map[string]FieldInterceptor `pkl:"target"`
Source *map[string]FieldInterceptor `pkl:"source"`
}
type Mapper ¶
type Mapper struct {
}
type Package ¶
type Package interface {
GetMode() string
GetInterfaceName() string
GetImplementationName() string
GetConstructorName() string
GetSourceToTargetFunctionName() string
GetSourceFromTargetFunctionName() string
GetDecoratorMode() decoratormode.DecoratorMode
GetPointer() pointer.Pointer
GetDecoratorInterfaceName() string
GetDecoratorNoopName() string
GetDecorateFunctionName() string
GetTargetPkg() string
GetSourcePkg() string
GetStructs() map[string]Struct
GetUseGetterIfAvailable() bool
GetGenerateSourceToTarget() bool
GetGenerateSourceFromTarget() bool
GetGenerateGoDoc() bool
}
type PackageImpl ¶
type PackageImpl struct {
// Controls the overall generation strategy.
//
// - "types": Generates an interface, implementation struct, and constructor.
// - "functions": Generates package-level mapping functions only (no interface or struct).
//
// Note: When mode = "functions", type-related naming options are ignored.
Mode string `pkl:"mode"`
// Name of the generated mapper interface.
//
// Used only when mode = "types".
// Defaults to a non-exported name to avoid polluting consumer APIs.
InterfaceName string `pkl:"interface_name"`
// Name of the generated mapper implementation struct.
//
// Used only when mode = "types".
ImplementationName string `pkl:"implementation_name"`
// Name of the constructor function for the mapper implementation.
//
// Used only when mode = "types".
ConstructorName string `pkl:"constructor_name"`
// Default template for source-to-target mapping function names.
// `{TargetStructName}` will be replaced with the actual target struct name.
//
// Can be overridden per struct.
SourceToTargetFunctionName string `pkl:"source_to_target_function_name"`
// Default template for target-to-source mapping function names.
// `{TargetStructName}` will be replaced with the actual target struct name.
//
// Can be overridden per struct.
SourceFromTargetFunctionName string `pkl:"source_from_target_function_name"`
// Controls whether and how decorators are generated.
//
// - "adaptive": Generate decorators only when customization hooks are needed.
// - "always": Always generate decorator types.
// - "never": Never generate decorators.
//
// Can be overridden per struct.
DecoratorMode decoratormode.DecoratorMode `pkl:"decorator_mode"`
// Controls pointer usage in generated mapping code.
//
// - "none": Neither source nor target is treated as a pointer.
// - "source-only": Source struct is passed as a pointer.
// - "target-only": Target struct is returned or populated as a pointer.
// - "both": Both source and target are pointers.
//
// Can be overridden per struct.
Pointer pointer.Pointer `pkl:"pointer"`
// Name of the generated decorator interface. Used only when decorator_mode != "never"
//
// Can be overridden per struct.
DecoratorInterfaceName string `pkl:"decorator_interface_name"`
// Name of the no-op decorator implementation. Empty string
// would skip the NoOp implementation.
//
// Used only when decorator_mode != "never"
DecoratorNoopName string `pkl:"decorator_noop_name"`
// Template for the decorator function name.
//
// `{FunctionName}` will be replaced with the decorated function name.
DecorateFunctionName string `pkl:"decorate_function_name"`
// Default target package for generated mapper code.
//
// Defaults to the current package where generation is invoked.
TargetPkg string `pkl:"target_pkg"`
// Default source package containing input structs.
//
// Can be overridden per struct.
SourcePkg string `pkl:"source_pkg"`
// Mapping definitions for this package.
//
// Each entry describes how a source struct maps to a target struct.
Structs map[string]Struct `pkl:"structs"`
// Whether to prefer getter methods over direct field access
// on source structs by default.
//
// Can be overridden per struct.
UseGetterIfAvailable bool `pkl:"use_getter_if_available"`
// Whether to generate source-to-target mapping code.
// When false, only target-to-source mapping is generated.
//
// Can be overridden per struct.
GenerateSourceToTarget bool `pkl:"generate_source_to_target"`
// Whether to generate target-to-source mapping code.
// When false, only source-to-target mapping is generated.
//
// Can be overridden per struct.
GenerateSourceFromTarget bool `pkl:"generate_source_from_target"`
// Whether to generate GoDoc comments for generated code.
GenerateGoDoc bool `pkl:"generate_go_doc"`
}
Base configuration for mapper code generation.
This configuration controls *how* mappers are generated (types vs functions), naming conventions of generated symbols, decorator behavior, and package layout.
func (PackageImpl) GetConstructorName ¶
func (rcv PackageImpl) GetConstructorName() string
Name of the constructor function for the mapper implementation.
Used only when mode = "types".
func (PackageImpl) GetDecorateFunctionName ¶
func (rcv PackageImpl) GetDecorateFunctionName() string
Template for the decorator function name.
`{FunctionName}` will be replaced with the decorated function name.
func (PackageImpl) GetDecoratorInterfaceName ¶
func (rcv PackageImpl) GetDecoratorInterfaceName() string
Name of the generated decorator interface. Used only when decorator_mode != "never"
Can be overridden per struct.
func (PackageImpl) GetDecoratorMode ¶
func (rcv PackageImpl) GetDecoratorMode() decoratormode.DecoratorMode
Controls whether and how decorators are generated.
- "adaptive": Generate decorators only when customization hooks are needed. - "always": Always generate decorator types. - "never": Never generate decorators.
Can be overridden per struct.
func (PackageImpl) GetDecoratorNoopName ¶
func (rcv PackageImpl) GetDecoratorNoopName() string
Name of the no-op decorator implementation. Empty string would skip the NoOp implementation.
Used only when decorator_mode != "never"
func (PackageImpl) GetGenerateGoDoc ¶
func (rcv PackageImpl) GetGenerateGoDoc() bool
Whether to generate GoDoc comments for generated code.
func (PackageImpl) GetGenerateSourceFromTarget ¶
func (rcv PackageImpl) GetGenerateSourceFromTarget() bool
Whether to generate target-to-source mapping code. When false, only source-to-target mapping is generated.
Can be overridden per struct.
func (PackageImpl) GetGenerateSourceToTarget ¶
func (rcv PackageImpl) GetGenerateSourceToTarget() bool
Whether to generate source-to-target mapping code. When false, only target-to-source mapping is generated.
Can be overridden per struct.
func (PackageImpl) GetImplementationName ¶
func (rcv PackageImpl) GetImplementationName() string
Name of the generated mapper implementation struct.
Used only when mode = "types".
func (PackageImpl) GetInterfaceName ¶
func (rcv PackageImpl) GetInterfaceName() string
Name of the generated mapper interface.
Used only when mode = "types". Defaults to a non-exported name to avoid polluting consumer APIs.
func (PackageImpl) GetMode ¶
func (rcv PackageImpl) GetMode() string
Controls the overall generation strategy.
- "types": Generates an interface, implementation struct, and constructor. - "functions": Generates package-level mapping functions only (no interface or struct).
Note: When mode = "functions", type-related naming options are ignored.
func (PackageImpl) GetPointer ¶ added in v0.8.0
func (rcv PackageImpl) GetPointer() pointer.Pointer
Controls pointer usage in generated mapping code.
- "none": Neither source nor target is treated as a pointer. - "source-only": Source struct is passed as a pointer. - "target-only": Target struct is returned or populated as a pointer. - "both": Both source and target are pointers.
Can be overridden per struct.
func (PackageImpl) GetSourceFromTargetFunctionName ¶
func (rcv PackageImpl) GetSourceFromTargetFunctionName() string
Default template for target-to-source mapping function names. `{TargetStructName}` will be replaced with the actual target struct name.
Can be overridden per struct.
func (PackageImpl) GetSourcePkg ¶
func (rcv PackageImpl) GetSourcePkg() string
Default source package containing input structs.
Can be overridden per struct.
func (PackageImpl) GetSourceToTargetFunctionName ¶
func (rcv PackageImpl) GetSourceToTargetFunctionName() string
Default template for source-to-target mapping function names. `{TargetStructName}` will be replaced with the actual target struct name.
Can be overridden per struct.
func (PackageImpl) GetStructs ¶
func (rcv PackageImpl) GetStructs() map[string]Struct
Mapping definitions for this package.
Each entry describes how a source struct maps to a target struct.
func (PackageImpl) GetTargetPkg ¶
func (rcv PackageImpl) GetTargetPkg() string
Default target package for generated mapper code.
Defaults to the current package where generation is invoked.
func (PackageImpl) GetUseGetterIfAvailable ¶
func (rcv PackageImpl) GetUseGetterIfAvailable() bool
Whether to prefer getter methods over direct field access on source structs by default.
Can be overridden per struct.
type Struct ¶
type Struct struct {
// Target package for the generated mapping code.
//
// Overrides package level target_pkg when set.
TargetPkg *string `pkl:"target_pkg"`
// Name of the target struct.
//
// If not set, the target struct name is inferred from context.
TargetStructName *string `pkl:"target_struct_name"`
// Source package containing the source struct.
//
// Overrides package level source_pkg when set.
SourcePkg *string `pkl:"source_pkg"`
// Name of the source struct.
//
// If not set, the source struct name is inferred from context.
SourceStructName *string `pkl:"source_struct_name"`
// Template for the source-to-target mapping function name.
//
// Overrides package level source_to_target_function_name when set.
SourceToTargetFunctionName *string `pkl:"source_to_target_function_name"`
// Template for the target-to-source mapping function name.
//
// Overrides package level source_from_target_function_name when set.
SourceFromTargetFunctionName *string `pkl:"source_from_target_function_name"`
// Template for the decorator function name.
//
// Overrides package level decorate_function_name when set.
DecorateFunctionName *string `pkl:"decorate_function_name"`
// Controls whether and how decorators are generated.
//
// - "adaptive": Generate decorators only when customization hooks are needed.
// - "always": Always generate decorator types.
// - "never": Never generate decorators.
//
// Overrides package level decorator_mode when set.
DecoratorMode *decoratormode.DecoratorMode `pkl:"decorator_mode"`
// Controls pointer usage in generated mapping code.
//
// - "none": Neither source nor target is treated as a pointer.
// - "source-only": Source struct is passed as a pointer.
// - "target-only": Target struct is returned or populated as a pointer.
// - "both": Both source and target are pointers.
//
// Overrides package level pointer when set.
Pointer *pointer.Pointer `pkl:"pointer"`
// Field-level mapping configuration.
//
// Controls how fields are matched and transformed between
// source and target structs.
Fields Fields `pkl:"fields"`
// Target's fields interceptors. This is a shortcut of fields { target }
// the value in both settings will be merged, the fields { target } will
// win if there is a duplication.
TargetFields *map[string]FieldInterceptor `pkl:"target_fields"`
// Source's fields interceptors. This is a shortcut of fields { source }
// the value in both settings will be merged, the fields { source } will
// win if there is a duplication.
SourceFields *map[string]FieldInterceptor `pkl:"source_fields"`
// Whether to prefer getter methods over direct field access
// on the source struct.
//
// Overrides package level use_getter_if_available when set.
UseGetterIfAvailable *bool `pkl:"use_getter_if_available"`
// Whether to generate source-to-target mapping code.
// When false, only target-to-source mapping is generated.
//
// Overrides package level generate_source_to_target when set.
GenerateSourceToTarget *bool `pkl:"generate_source_to_target"`
// Whether to generate target-to-source mapping code.
// When false, only source-to-target mapping is generated.
//
// Overrides package level generate_source_from_target when set.
GenerateSourceFromTarget *bool `pkl:"generate_source_from_target"`
}
Configuration for mapping between a specific source struct and a specific target struct.
Values defined here override corresponding values in `BaseMapper` when explicitly set. Unset (null) values fall back to the base configuration defaults.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Code generated from Pkl module `gomappergen.mapper`.
|
Code generated from Pkl module `gomappergen.mapper`. |
|
Code generated from Pkl module `gomappergen.mapper`.
|
Code generated from Pkl module `gomappergen.mapper`. |