README ¶
envflagset
Parse FlagSet from ENV
example
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
Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseEnv ¶
ParseEnv parses all registered flags in the given flagset, and if they are not already set it attempts to set their values from environment variables. Environment variables take the name of the flag but are UPPERCASE, have the prefix "PREFIX_", and any dashes are replaced by underscores - for example: some-flag => PREFIX_SOME_FLAG
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.