uber-go / mapdecode Goto Github PK
View Code? Open in Web Editor NEWImplement YAML/JSON decoding in one place.
License: MIT License
Implement YAML/JSON decoding in one place.
License: MIT License
.travis.yml is already in place so we just need to enable Travis for this repo
It's not really needed because srcData
knows its type (since it's a valid reflect.Value
).
Rather than farming out bits and pieces of these projects as public micro-repos, can we get all the bits working fully and vetted in production internally?
Field Hooks allow interpolation on struct fields (most commonly used to add environment variables to strings). So if I have a struct:
type Config struct {
MyField: `config:"field,interpolate"`
}
I can specify the config field as config: hello${MYENVVAR:backup}
which will use the environment variable if it is available or fallback to "backup".
The issue happens if I embed structs. So if I have:
type Config struct {
SubConfig
}
type SubConfig struct {
MyField: `config:"field,interpolate"`
}
The code for Field Hooks does not properly interpolate the MyField
struct field (i.e. we don't interpolate env vars).
I've narrowed this down to this for loop when determining to interpolate fields:
https://github.com/uber-go/mapdecode/blob/master/hooks.go#L233
This for loop does not account for embedded structs.
We can compare this to the decodeStruct
method that iterates over embedded structs here:
https://github.com/uber-go/mapdecode/blob/master/internal/mapstructure/mapstructure.go#L701
Proposal: We should update the FieldHook function to iterate over the embedded structs similar to the decodeStruct
method
Thoughts: @prashantv @abhinav @breerly @akshayjshah
(Mostly wondering if this was a conscious choice before implementing)
Let's cut a v0.1.0 so that libs can start evaluating whether we've gotten the shape of this problem right or not.
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.