Changelog
unreleased
v1.9.2
- Fix comparison of signatures with aliases in
extendand conversion methods. (#213 via #215)- This is a regression introduced in v1.9.1 due to the x/tools upgrade.
- Upgrade toolchain to go1.25. (#214)
v1.9.1
- Increase minimal go version to go1.23 due to breaking changes in x/tools for go1.24 (#208)
- Improve conversion of
*TtoT. (#205 via #206)
v1.9.0
- Add automatic conversion of arrays with same size (#202 via #204)
- Fix missing initialization on array to slice conversion (#203 via #204)
v1.8.3
v1.8.2
v1.8.1
- Allow specifying
goverter:settings without leading space e.g.//goverter:converter(#190 via #191) - Fix SEGSEGV with enabled
useUnderlyingTypeMethods(#192 via #193)
v1.8.0
- Fix go1.24 support. (#186 via #187)
- Increase minimal go version to go1.22 due to breaking changes in x/tools for go1.24 (#187)
- Infer
output:packagefrom file location (#180 via #181)
v1.7.0
- Remove default value of
arg:context:regex(#68 via #176)- To get v1.6.0 behavior, configure:
goverter:arg:context:regex ^ctx|^context - The recommended way to configure context is to use
context.
- To get v1.6.0 behavior, configure:
- Add
context. See Guide: Pass context to functions (#68 via #176) - Add
default:update(#171 via #175) - Fix not setting
nilon map when value isnil. (#173 via #175)
v1.6.0
- Support for passing context to functions. (#68 via #166)
- Support updating an existing instance of a struct (#147 via #170)
- Add
output:raw CODE(#113 via #168) - Error on duplicated converter signatures. (#146 via #166)
- Fix panic when using
chanin conversion functions. (#165 via #167)
v1.5.1
v1.5.0
- Add two input-output formats. See Guide: Input/Output formats for help to choose a format. The new formats allow you to call top level functions without the need to instantiate a struct to call methods on it. (#77 via #149)
- Add
variablessetting - Add
output:formatsetting
- Add
- Add line numbers of originating definitions to all error messages. (#149)
v1.4.1
- Error when the settings
enumanduseUnderlyingTypeMethodsconflict. (#141 via #142) - Add CLI commands
helpandversion. (#144 via #145) - Improve generation by assigning variables directly if possible. (#97 via #148)
Examples
difffunc (c *ConverterImpl) Convert(source execution.Input) execution.Output { var structsOutput execution.Output - var pString *string if source.Nested.Name != nil { xstring := *source.Nested.Name - pString = &xstring + structsOutput.Name = &xstring } - structsOutput.Name = pString return structsOutput }difffunc (c *ConverterImpl) ConvertPToP(source []*int) []*int { var pIntList []*int if source != nil { pIntList = make([]*int, len(source)) for i := 0; i < len(source); i++ { - var pInt *int if source[i] != nil { xint := *source[i] - pInt = &xint + pIntList[i] = &xint } - pIntList[i] = pInt } } return pIntList }
v1.4.0
- Add Enum Support (#61 via #136) . Can be disabled via
enum no. - Add
wrapErrorsUsing(#134) - Fix panic with go1.22 (#135 via #133)
- Require go1.18 for building Goverter (#133)
- Add current working directory
-cwdoption to CLI (#134) - Fix error messages when there is an return error mismatch (#136)
- Fix panic when using type params in
extend,mapordefault. (#138 via #139) - Fix
types.Alias. See golang#63223
internals:
v1.3.2
Change generated directory permissions from 777 -> 755 and generated file permissions from 777 -> 644. This only affects newly created files and directories. Existing files and directories will keep their current permissions. (#128 via #129)
v1.3.1
Fix nil map conversion. A nil map of will be converted to a nil map of the target type. Previously, the target map was instantiated via make with a 0 size. (#126 via #127)
v1.3.0
- Fix absolute paths in
output:file(#116) - Error on internally overlapping struct methods (#114 via #117)
- Scan packages with build constraints. (#111 via #118)
ignoreno longer ignores source fields in combination withautoMap(#120)- Error on not existing target fields with field settings (#120)
- Error when using a path as target field (#120)
internals:
- Migrate documentation to vitepress (#118)
v1.2.0
- Support using unexported fields, methods and functions when they are accessible from the
output:package(#104 via #107) - Fix ignored field settings for conversions from non pointer to pointer types (#104 via #107)
- Improve error messages for
*TtoTconversions (#105 via #106) - Error on overlapping internal sub methods (#105 via #106)
internals:
- Execute tests in parallel (#108)
v1.1.1
Fix a panic when using the error type inside the conversion.
v1.1.0
- Add
struct:comment(#94) - Add
useUnderlyingTypeMethods(#78 via #95) - Add
default(#93 via #96) - Allow mapping source methods to the target field.
mapsupports method calls as source-path. (#91 via #99) - Don't panic on
func()types (#99) - Improve error messages (#98)
- add outline of conversion generation generation (#99)
v1.0.0
- Major rework of documentation. See settings (#92)
- Rework of the CLI (#92)
- Improve handling of boolean flags, allow disabling these settings for single methods. See define (#92)
- Add
output:fileoutput:patternsettings:output(#92) - Remove deprecated
mapExtendmapIdentity: migrations (#92) - Refactor internals for upcoming features (#92)
- Remove pkg/errors dependency (#92)
- Improve error messages (#92)
See migrations for instructions to migrate to this version. If you have problems with this release please create a ticket in this project.
v0.18.0
Add skipCopySameType, this setting instruct Goverter to skip copying instances when the source and target type is the same.
v0.17.5
Prevent unused variables in generated code when empty structs are used
(#82 via #83)v0.17.4
Fix endless loop when converting nested recursive types.
(#73 via #74)v0.17.3
Fix panic when generating a conversion method containing the type map[string]interface{}. (#71 via #72)
v0.17.2
Readd go1.16 support for building goverter, it broke with v0.17.1.
(#69 via #70)v0.17.1
Fix generation of types with generic arguments (#66 via #67)
v0.17.0
- Add
goverter:useZeroValueOnPointerInconsistency(#64 via #65) - Allow defining
matchIgnoreCaseon the converter interface (54d551)
v0.16.0
- Add
ignoreMissing(#60) - Add
ignoreUnexported(#60)
v0.15.0
- Improve code generation for errors (#19 via #57)
- Add
goverter:autoMap(#55 via #59)
v0.14.0
- Prevent value copying of source struct pointers if possible. This should fix "go vet copylocks" warnings, because some structs should not be copied. See (#39 via #56)
- Due to the change above, the generated code will look different, because goverter now splits internal converter methods differently. The overall behavior of the implementation shouldn't change. (#56)
- Error on overlapping field mappings. This doesn't change how config is evaluated, but it does now error when field mapping config like
goverter:mapis at the wrong converter method and would be ignored. (#56)
v0.13.0
- Fix docs links in error messages
- Allow using external packages in
map(#47 via #50) - Allow returning an error in
map(#43 via #50) - Error on misconfiguration (#8 via #51)
v0.12.0
- Deprecation:
goverter:mapExtendwill be removed soon. See migration. - Deprecation:
goverter:mapIdentitywill be removed soon. See migration - Add support for unnamed structs (#41 via 6287f1)
- Add documentation https://goverter.jmattheis.de/ (#49)
- Allow defining a custom conversion for only a specific field. See
map(#49)
v0.11.1
Fix pointer slice conversion
(#40 via be3874)v0.11.0
Allow passing self in mapExtend method
v0.10.1
- Improve error message on compile errors (#35)
- Fix
goverter:mapIdentitywith pointer types (#36 via feeafb)
v0.10.0
By default, goverter will fail if you don't ignore all unexported fields. To automatically ignore all unexported fields, you can enable ignoreUnexported (#31 via #32)
v0.9.0
Add wrapErrors (#29)
v0.8.1
Use extend method when converter method with same method exists
(#26 via 12cc64)v0.8.0
Add mapExtend FIELD METHOD (#25)
v0.7.0
Allow setting the packagePath of the generated converter to prevent import loops. (#22)
v0.6.3
v0.6.2
Fix compile errors in code generation with error in return type
v0.6.1
Error using extend on unexported method (#17)
v0.6.0
Add matchIgnoreCase (#16)
v0.5.0
Add working directory setting. (#15)
v0.4.0
v0.3.0
Add mapIdentity FIELD. (#12 via #13)
v0.2.0
v0.1.2
Fix map & ignore for struct pointer
v0.1.1
Add tests
v0.1.0
Initial Release