synthesio / zconfig Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The configuration repository is used to fill the struct from the various configuration sources (cli, env, file, etc).
The error message should describe the shortest cycle detected by their path, so the end-user can know what was wrong exactly. We don't need anything fancy from graph theory, since this is not something that is important once the structure is right. The simpler naive algorithm will do.
Hi team,
After having a closer look at the code and documentation, I realized that the library depends on two non-std libs, based on the godoc link https://godoc.org/github.com/synthesio/zconfig?imports
github.com/pkg/errors
for error handlinggithub.com/fatih/structtag
for structure tag listingWould it be possible to get rid of those two dependancies ?
I would like to see a section about other existing tools (go-flags ...) and another one about why we had to write this library (and so not using the existing ones).
It's a common pattern to see this on a library it helps to understand the differences and what can be achieved with the current library
The hook system can be used to extend capabilities and custom behavior.
Is your feature request related to a problem? Please describe.
Right now we have no way to know what provider provided a config. Sometimes when debugging or monitoring purpose it would be interesting to know if a parameter comes from arguments, environment variables or from the default value.
Describe the solution you'd like
I propose to implement something, I will open an PR
Describe alternatives you've considered
Right now, there is no alternative except copy pasting the repository code in an external lib to store the provider information.
Additional context
None
Describe the bug
The environment seems to be parsed before the first call to zconfig.Configure()
. This prevent usage of os.Clearenv()
or os.Setenv()
To Reproduce*
// /tmp/zconfigbug.go
package main
import (
"fmt"
"os"
"github.com/synthesio/zconfig"
)
func main() {
os.Clearenv()
type Container struct {
Foo string `key:"foo" default:"foo"`
}
var c Container
_ = zconfig.Configure(&c)
fmt.Println(c.Foo)
}
FOO="bar" go run zconfigbug.go
bar
Expected behavior
FOO="bar" go run zconfigbug.go
foo
Additional context
I use zconfig to setup my applications. The db layer is tested against a docker, witch address is different from the dev environment. dev comes from environment, test is default values.
MYSQL_DSN=root:rootpass@tcp(localhost:3303)/mytable #dev
type DB struct{
*sql.DB
DSN string `key:"dsn" default:"user:password@tcp(localhost:3306)/mytable"`
A simple but comprehensive explanation in the readme wll do.
Hello team,
Thanks for the great work you have done in open sourcing the lib.
I believe that the README could be enhanced however. In the I want to read my configuration from "insert source name here" section, the example is given with github.com/tidwall/gjson
. I think it would be easier to understand with the std encoding/json
lib.
Right now the tests are present but there is no way to test them locally or directly on github
Describe the bug
In case of circular dependency withing the target of zconfig.Configure, the function is caught in an infinite loop.
This has been detected using gorm.io/gorm.DB v1.22.4
To Reproduce
package main
import (
"fmt"
"github.com/synthesio/zconfig"
"gorm.io/gorm"
)
type Service struct {
*gorm.DB
}
func main() {
fmt.Println("start")
zconfig.Configure(new(Service))
fmt.Println("done")
}
Expected behavior
We expect zconfig to properly walk through the service, whether it embeds a circular dependency or not.
Both simple examples and more complex demos, so new users can be getting started quickly.
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.