Comments (6)
Yep, the current behaviour is to overwrite the previous values in subsequent merges. To add type checks and other similar features, roughly:
- Add a
NewWithConf(delim, koanf.Conf{})
that takes a newkoanf.Conf{}
that can contain arbitrary feature flags. koanf.Config { bool StrictMerge }
- Make
merge()
behave differently based on this config value. - Will probably need a
MergeStrict()
in themaps
package as well.
from koanf.
Thank you for the quick response!
Should I merge the delim
field in the new koanf.Config
?
from koanf.
Ah yes, makes sense.
from koanf.
maps.MergeStrict
has to return an error since the merging process can fail.
In koanf
, merge
is used in 4 places:
- Load - can return an error.
- Cut - cannot return an error - but okay since it's a subset.
- Merge - cannot return an error - possible mergeStrict errors.
- MergeAt - cannot return an error - possible mergeStrict errors.
As I see it since the koanf.Conf
has MergeStrict: true
it should affect all the merging behavior across koanf
.
Possible solutions:
- We can either exclude
koanf.Merge
andkoanf.MergeAt
by addingkoanf.MergeStrict
andkoanf.MergeStrictAt
and ignore thekoanf.Conf
- We can ignore MergeStrict flag in
koanf.Merge
andkoanf.MergeAt
functions - Change
koanf.Merge
andkoanf.MergeAt
signatures so it will return an error. I think it will not break backward compatibility.
I'm up for number 3, WDYT?
from koanf.
3 is the cleanest approach. We can bump the version to 1.0.0 after this. Long overdue.
from koanf.
Merging between JSON and YAML will fail because of the float64
/int
issue.
We can either say that you cannot MergeStrict
between YAML and JSON and the recommended way is to use mergeStrict between the same types, or we can check if float64 is a whole number and convert to int but it will not cover cases where user-defined a whole float number: 3.0
but we can only patch one case where in the future there could be more of them.
from koanf.
Related Issues (20)
- [Bug] Parsing a string from the YAML file with XML/HTML tags HOT 1
- Is it possible to load config to the slice of structs? HOT 4
- How to stop file watcher? HOT 3
- Is it possible to define a parameter reference another parameter in mock.toml file? HOT 1
- How to retrieve/print the final YAML string after YAML files are loaded and merged? HOT 5
- Alternativ to pflag? HOT 4
- basicflag Provider does not exclude default values HOT 3
- Why not create new file when file not exists. HOT 1
- Read enviroments secrets from github HOT 2
- Can not parse environment variable HOT 1
- Switch from mitchellh/mapstructure to go-viper/mapstructure HOT 14
- Can't unmarshall env variable with multiple words
- Support for merging slices HOT 2
- File watching error when saving with vi/vim or neovim HOT 1
- How to populate a map[string]string from environment variables HOT 1
- When loading with providers/env, koanf.Unmarshal doesn't work. HOT 5
- koanf.Unmarshal doesn't work when loaded with env provider HOT 2
- Default values from Tags for missing config values HOT 2
- posflag provider overrides values even if flags are not set for special delimiters HOT 1
- Convert non-string type to string in StringMap() HOT 1
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 koanf.