Comments (8)
Thank you.
from mergo.
This is the expected behavior.
@darccio does this mean it is not possible to merge booleans at all using this tool then? If we cannot rely on it respecting a legitimate value of false? Or do you have a recommendation for how to get around this?
It would be unfortunate if so as it would make it unusable for anyone with boolean values in their yaml, and otherwise the tool is brilliant. :(
from mergo.
This is the expected behavior. As stated in README:
Mergo is intended to assign only zero value fields on destination with source value.
The zero value of a boolean field is false. It isn't possible to avoid it even with a pointer because Merge follows the pointers too. So, when it finds a pointer to bool with false value, it will overwrite with a true value if src matching field is true.
If you have any doubt, don't hesitate to ask me.
from mergo.
For those of you who need it, @Pothulapati built a fork that solves this here.
from mergo.
i think that for bool case we need to add additional logic
from mergo.
i think that for bool case we need to add additional logic
Do you mean in the mergo repo or where it is being called?
from mergo.
i think that for bool case we need to add additional logic
Do you mean in the mergo repo or where it is being called?
in mergo repo, but i dont know how to detect false vs not set =)
from mergo.
Here is 3 ways to handle merge boolean the way we would like:
- Using
mergo.WithOverwriteWithEmptyValue
#129 (comment) but the drawback is that empty values won't be kept - Using a customBoolean Type see #129 (comment)
- Treat boolean as string
from mergo.
Related Issues (20)
- Transformers: How to access underlying datatype HOT 1
- mergo WithSliceDeepCopy into differen types will causes painc
- Missing merge only empty dst and check empty value not work for struct HOT 1
- WithSliceDeepCopy cannot merge nums in slice. Suggestion: Recomplete it as WithRecursiveOverride HOT 1
- Mergo not overriding destination with source HOT 2
- Docs: “Mergo in the wild” inaccurate HOT 2
- Mergo is not overriding destination map key with empty value with WithOverwriteWithEmptyValue
- Add support OSS-Fuzz
- Merge Slices HOT 6
- bool values are not merged properly HOT 7
- New module path breaks go install of package with indirect dependency on mergo HOT 13
- How to overwrite specified field with empty value in struct HOT 1
- Choosing fields of struct to override
- Vanity name makes live hard for developers HOT 9
- Vanity url doesn't redirect to github repo HOT 5
- module declares its path as: dario.cat/mergo but was required as: github.com/imdario/mergo HOT 7
- bool issue HOT 2
- unable to go get package
- dario.cat has expired HOT 3
- When a struct is converted to a map, can the key values of the map be of a custom format?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mergo.