This repository was archived by the owner on Mar 24, 2026. It is now read-only.
nirmata/go-envflag
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Define flags via command-line and / or environment variables.
This library allows definition of command line flags that use
environment variable values, when available, as defaults. This
is especially useful for containerized applications.
_______________________________________________________
Usage example:
import "envflag"
var (
// flagB will be set to 'myflag' if specified on the command line, or
// MY_ENV_VAR if specified as an environment variable, or defaultValue
// if neither myflag or MY_ENV_VAR are specified.
flagB = envflag.Bool("myflag", "MY_ENV_VAR", defaultValue, "a boolean flag")
)
envflag.Parse()