Giter VIP home page Giter VIP logo

Comments (5)

ilyakaznacheev avatar ilyakaznacheev commented on July 30, 2024 1

@vlaabra that's already possible. Just read from any sources you want, just keep in mind that the last read may override the previous one if there is a common field in both sources.

from cleanenv.

ilyakaznacheev avatar ilyakaznacheev commented on July 30, 2024

Thanks!
Could you give an example of the logic you're asking about?

from cleanenv.

vlaabra avatar vlaabra commented on July 30, 2024
cleanenv.ReadConfig("config.yml", &cfg)
cleanenv.ReadConfig("db/conf.yml", &cfg)

🤷‍♂️

from cleanenv.

ilyakaznacheev avatar ilyakaznacheev commented on July 30, 2024

Say, you have a two config files, cfg_1.yml:

one: 1

and cfg_2.yml:

two: 2

Then the following code

	type config struct {
		One int `yaml:"one"`
		Two int `yaml:"two"`
	}

	cfg := config{}
	cleanenv.ReadConfig("cfg_1.yml", &cfg)
	cleanenv.ReadConfig("cfg_2.yml", &cfg)
	fmt.Printf("%+v", cfg)

will output

{One:1 Two:2}

Sure if there would be one: 123 in the second file, it would rewrite the value from the first one.

Simple enough and no side-effects 😎

from cleanenv.

ilyakaznacheev avatar ilyakaznacheev commented on July 30, 2024

So, since we've figured out that it's already been implemented, I'm closing the issue.

from cleanenv.

Related Issues (20)

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.