Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

short-d/envconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EnvConfig

Organize configs in a clean way.

TODO

  • Support parsing configs from remote key value store, such as ZooKeeper or Redis

Getting Started

  1. Install the library.

    go get github.com/short-d/envconfig
  2. Parse configs from environmental variables.

    import "github.com/short-d/envconfig"
    
    envConfig := envconfig.NewDefault()
    
    config := struct {
        DBHost     string `env:"DB_HOST" default:"localhost"`
        DBPort     int    `env:"DB_PORT" default:"5432"`
        DBUser     string `env:"DB_USER" default:"postgres"`
        DBPassword string `env:"DB_PASSWORD" default:"password"`
        DBName     string `env:"DB_NAME" default:"sampleapp"`
    }{}
    err := envConfig.ParseConfigFromEnv(&config)
    if err != nil {
        panic(err)
    }

License

This project is maintained under MIT license.

About

Organize configs in a clean way.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages