psiphon-inc / configloader-go Goto Github PK
View Code? Open in Web Editor NEWConfig loading library for Go
License: BSD 3-Clause "New" or "Revised" License
Config loading library for Go
License: BSD 3-Clause "New" or "Revised" License
There might be no good reason to have type checking over and above what the codec unmarshaler provides. In theory it would be good if an unmarshaler didn't provide sufficient type checking (and just silently filled in zero values, say), but we haven't yet found an example where our type checking catches something that gets passed encoding/json or BurntSushi/toml. And it's quite a lot of additional complexity (and bug potential -- like catching conflicts that aren't really conflicts).
If removed, it would affect these things:
SupportsTextUnmarshaler() bool
. Use that to prevent recursion into the struct (like, into the fields of time.Time or whatever). (Maybe get even fancier and pass in reflect info and let the method do interface satisfaction checking. This might also give us BinaryUnmarshaler support.)A structure like this:
struct {
M map[string]int
}
With config like this:
[M]
a = 1
b = 2
...Will fail the consistency check. The map representation of the config used for checking reports M
as map[string]interface{}
, which fails the type comparison. Example: https://github.com/ascottAtPsiphon/configloader-example
There are tests for map[string]interface{}
fields, not but more strongly typed maps.
For example, for a config like:
type Config struct {
M map[string]int
}
An environment override like:
[]configloader.EnvOverride{
{
EnvVar: "MYVAR",
Key: configloader.Key{"M", "a"},
},
}
...Will result in an error about M.a
not being found in the struct.
The code should detect that M
is a map and relax the consistency check.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.