forked from darccio/mergo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use isReflectNil instead of isEmptyValue to gate Transformers
Mergo handles merges with zero-value fields as follows: 1. dst: true src: false -> dst: true 2. dst: nil src: false -> dst: false 3. dst: nil src: true -> dst: true 4. dst: false src: true -> dst: true In some cases (darccio#166) it may be desirable to change this default behaviour using a custom Transformer, for example to not overwrite 'dst' when it's already set to 'false' (or '0' etc). Unfortunately, in such cases (when dst holds a zero-value) no Transformers can be applied due to the way these are gated (darccio#166). Here we are changing how transformers are gated by using the isReflectNil function insted of isEmptyValue. Note that: - this change doesn't affect the default behaviour of mergo, as it only affects how transformers are gated - since custom transformers need to match data types in order to execute, this shouldn't affect any existing transformers either
- Loading branch information
Showing
3 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
language: go | ||
|
||
go: | ||
- "1.13" | ||
- "1.14" | ||
- "1.15" | ||
- "1.16" | ||
- "1.17" | ||
|
||
arch: | ||
- amd64 | ||
- ppc64le | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters