Coder Social home page Coder Social logo

zconfig's People

Contributors

ccoveille avatar dgsb avatar dsiragusa avatar elwinar avatar hchargois avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

zconfig's Issues

Improve the "cycle detected" error message

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.

Add a section in README.md about other tools

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

Add the provider information to the field

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

Env is parsed before first call to zconfig.Configure

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"`

[README] simplify json exemple

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.

Add CI for the tests

Right now the tests are present but there is no way to test them locally or directly on github

Infinite loop on circular dependency

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.

Add examples

Both simple examples and more complex demos, so new users can be getting started quickly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.