Documentation ¶
Overview ¶
Package configfile provides the configfile.SourceInfo struct that gives the config file properties: path, format and source.
Example (SanitizeEnvKey) ¶
fmt.Println(sanitizeEnvKey("appname")) fmt.Println(sanitizeEnvKey("app-name")) fmt.Println(sanitizeEnvKey("az_AZ-09")) fmt.Println(sanitizeEnvKey("a=p_p n+a(m)e"))
Output: APPNAME APP_NAME AZ_AZ_09 A_P_P_N_A_M_E
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SourceInfo ¶ added in v0.3.0
type SourceInfo struct {
// contains filtered or unexported fields
}
SourceInfo representes the information about the config file.
func NewSourceInfo ¶ added in v0.3.0
func NewSourceInfo(appname, keyPrefix, path, format string, passed bool) (*SourceInfo, error)
NewSourceInfo init the config file information struct from (in order): 1. command line 2. environment variables 3. defaults
Arguments:
appname: name of the app keyPrefix: prefix of the environment variables. If empty, apname will be used path: path of the config file passed as command line argument. It can be empty format: format of the config file passed as command line argument. It can be empty passed: true if path is passed as command line argument
func (*SourceInfo) Format ¶ added in v0.3.0
func (i *SourceInfo) Format() string
Format returns the (lowercase) config file format base the following criteria: 1. the explicitly passed format, or 2. the extension of the path without the leading "." It returns "" in case of nil object.
func (*SourceInfo) Path ¶ added in v0.3.0
func (i *SourceInfo) Path() string
Path returns the confg file epath
func (*SourceInfo) String ¶ added in v0.3.0
func (i *SourceInfo) String() string
String returns a representation of the configfile.Info object
Click to show internal directories.
Click to hide internal directories.