Documentation ¶
Overview ¶
Package flagcfg populates flags from a TOML config file. Each flag is assumed to have an optional top-level value in the config file, having the same name. However, if a flag contains a dash or a period, those are converted to underscores.
Flags that have already been assigned are not overwritten.
This package can be used together with github.com/facebookgo/flagenv to load flags from a config file, environment variable, or command-line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDefaultFiles ¶
func AddDefaultFiles(envName, cfgName string)
AddDefaultFiles adds default config file locations to search, using the given environment variable name and name of the config file to look for (excluding path).
func AddDefaults ¶
func AddDefaults()
AddDefaults adds default config file locations, using the binary name as a base. It will look for the file specificed by {NAME}_CONFIG, as well as "{NAME}.config" in various locations.
func Filename ¶
func Filename() string
Filename returns the name of the config file that was parsed by Parse()
func FindConfig ¶
func FindConfig() string
FindConfig returns the first config file that exists in the list.
Types ¶
type Locator ¶
type Locator struct {
// contains filtered or unexported fields
}
Locator can be used to find a given configuration file from a list you set up.
func (*Locator) AddDefaultFiles ¶
AddDefaultFiles adds default config file locations to search, using the given environment variable name and name of the config file to look for (excluding path).
func (*Locator) AddDefaults ¶
func (c *Locator) AddDefaults()
AddDefaults adds default config file locations, using the binary name as a base. It will look for the file specificed by {NAME}_CONFIG, as well as "{NAME}.config" in various locations.
func (*Locator) FindConfig ¶
FindConfig returns the first config file that exists in the list.