https://github.com/wealthworks/envflagset
Parse FlagSet from ENV
https://github.com/wealthworks/envflagset
env flag flagset golang
Last synced: 5 months ago
JSON representation
Parse FlagSet from ENV
- Host: GitHub
- URL: https://github.com/wealthworks/envflagset
- Owner: wealthworks
- License: mit
- Created: 2016-03-25T09:29:01.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-03-27T02:40:03.000Z (over 9 years ago)
- Last Synced: 2024-06-19T05:44:16.429Z (about 2 years ago)
- Topics: env, flag, flagset, golang
- Language: Go
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
envflagset
==========
Parse FlagSet from ENV
## example
````go
import (
"flag"
envcfg "lcgc/platform/envflagset"
)
var (
fs *flag.FlagSet
HttpListen string
CoreDSN string
)
func init() {
fs = envcfg.New("app", "0.0.1")
fs.StringVar(&HttpListen, "http-listen", "localhost:5000", "bind address and port")
fs.StringVar(&CoreDSN, "core-dsn", "mysql://user:pass@localhost:3306/appdb", "core database connecting string")
}
func main() {
envcfg.Parse()
// start app
}
// env:
// export APP_HTTP_LISTEN="localhost:5002"
// ./app
````