Skip to content
/ config Public

Environment and JSON based configuration. So simple it hurts.

Notifications You must be signed in to change notification settings

sno6/config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Config 📃

License: MIT

Easily handle JSON and environment based config in one go.

Example

// Define your projects configuration.
// 
// Validation is handled by https://github.com/go-playground/validator
type OurConfig struct {
    FromJSON string `json:"from_json" validate:"required"`
    FromEnv  string `env:"FROM_ENV" validate:"required"`
}

// Specify where to find your projects configuration files.
var cfg OurConfig
err := config.NewFromFile(&config.Config{
    Path:        "./config",
    Environment: config.Local,
}, &cfg)

// If there were no validation errors cfg will now be populated with values from 
// the local JSON file as well as the environment.

More examples can be found here.

Dependencies

go-env For marshalling from the environment.
validator For validation.

Releases

No releases published

Packages

No packages published

Languages