Comments (2)
I don't think this is a bug. The equivalent of LoadData here should be loading map[string]any, without pointer. Becasue when you create struct, zero values are assigned automatically.
When LoadFile, contents are converted to map[string]any instead of a predefined struct.
LoadData uses mergo.Merge(..., merge.WithOverride)
. It will override "non-empty" attributes, which is desired in most use cases. (e.g. intentional override some int field to 0).
I did not find a way to differentiate "user assigned zero value" vs "automatic zero value" in a struct. If there is, then adding a custom mergo.Transformers
might do.
from config.
hi @yz3358 @Adzikus On https://github.com/gookit/config/releases/tag/v2.2.5, add new option: MergeOptions support custom the data merge options
from config.
Related Issues (20)
- Add Duration type support HOT 2
- ReloadFiles方法在重载json格式的文件时会发生错误但toml正常
- Support slice with ParseEnv HOT 1
- Panic on missing key/value HOT 1
- More of a question setDecoder manually HOT 3
- yaml Binding ist not working correctly HOT 1
- 结构体中包含数组字段,数组中的子结构体字段设置默认值不生效。 HOT 8
- String Durations are not parsed with ParseTime and ParseEnv
- 监听文件变更,删除配置信息未改变 HOT 6
- Consider the notion of profiles/environments for configuration files HOT 1
- Fail fast for required values HOT 2
- Make parameter expansion scheme great again HOT 1
- 默认值解析空数组时,会自动生成一个元素(附带上默认值) HOT 2
- LoadFromDir 返回类型 HOT 6
- support parsedefault from defaultfile
- LoadOSEnvs not work HOT 4
- mergo 版本 HOT 1
- How to add desc msg to config flag
- 如何将config配置文件的默认值保存为一个默认配置文件?
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 config.