Documentation
¶
Index ¶
- func About()
- func BuildDate() time.Time
- func BuildNumber() int64
- func Contains(key string) bool
- func Load(key string) error
- func LoadAll() error
- func Remove(key string)
- func StringValue(key string) string
- func Version() string
- type Collection
- func (col Collection) Add(key string) *Item
- func (col Collection) Contains(key string) bool
- func (col Collection) Get(key string) *Item
- func (col Collection) Load(key string) error
- func (col Collection) LoadAll() error
- func (col Collection) Remove(key string)
- func (col Collection) StringValue(key string) string
- type Item
- func (ci *Item) LoadValue() error
- func (ci *Item) SetCliValueFlags(shortflag, longflag, usage string)
- func (ci *Item) SetDefaultValue(default_value string)
- func (ci *Item) SetEnvVar(name string)
- func (ci *Item) SetFileContentsFlags(shortflag, longflag, default_path, usage string)
- func (ci Item) StringValue() string
- type LoadMethod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildNumber ¶
func BuildNumber() int64
func StringValue ¶
Types ¶
type Collection ¶
var DefaultCollection Collection
func NewCollection ¶
func NewCollection() Collection
func (Collection) Add ¶
func (col Collection) Add(key string) *Item
add a config item to our "library" of items will panic if ENV_VAR_NAME is empty CliFlag and JSONKey can be empty, and will default to ENV_VAR_NAME typically, CliFlag is shorter and easy to type and JSONKey is empty or a lowercase, snake case variant of ENV_VAR_NAME
func (Collection) Contains ¶
func (col Collection) Contains(key string) bool
func (Collection) Get ¶
func (col Collection) Get(key string) *Item
func (Collection) Load ¶
func (col Collection) Load(key string) error
func (Collection) LoadAll ¶
func (col Collection) LoadAll() error
func (Collection) Remove ¶
func (col Collection) Remove(key string)
type Item ¶
type Item struct {
Key string // required
// method cli flag
Longflag string // long version of cli flag, such as -version. if "", we don't set a long flag
Shortflag string // short version of cli flag, such as -v. if "", we don't set a short flag
FlagUsage string // help message for cli flag(s)
// method: environment variable value
ENV_VAR_NAME string // environment variable name. if "" this variable cannot be loaded from environment variable
// method: read a file, use contents of file as value
FileContentsPathLongFlag string // a cli flag that tells where to load a file and use the entire contents of the file as the config variable.
FileContentsPathShortFlag string // a cli flag that tells where to load a file and use the entire contents of the file as the config variable.
FileContentsDefaultPath string // default value to look for file to read and use entire contents as value of config var
FileContentsUsage string
// method Json file
JSONFilePathLongFlag string
JSONFilePathShortFlag string
JSONFileDefaultPath string
Json_key string // lookup key for pulling value out of a json map. if "", this variable cannot be loaded from a json file
DefaultValue string // none of the methods work? use this default value
RawValue string // value we load from ENV, cli flag, file, etc.
LastLoad time.Time // when did we last attempt to load?
LoadMethod LoadMethod // how was the value loaded?
RawSet time.Time // when was Raw Value successfully set?
// contains filtered or unexported fields
}
we use wonky casing to hint what the standard usage is.
func Add ¶
add a config item to our "library" of items will panic if ENV_VAR_NAME is empty CliFlag and JSONKey can be empty, and will default to ENV_VAR_NAME typically, CliFlag is shorter and easy to type and JSONKey is empty or a lowercase, snake case variant of ENV_VAR_NAME
func NewItem ¶ added in v0.1.1
add a config item to our "library" of items will panic if `key` is empty if ENV_VAR_NAME is "", then LoadValue() won't check environment variables. if Shortflag and/or longflag is "", LoadValue() won't check cli flags. if JSONKey is "", LoadValue() won't check json file. typically, environment variables are all caps and words are separated by underscores (_) typically, CliFlag is shorter and easy to type and JSONKey is empty or a lowercase, snake case variant of ENV_VAR_NAME
func (*Item) SetCliValueFlags ¶
for now, we only support strings...
func (*Item) SetDefaultValue ¶
func (*Item) SetFileContentsFlags ¶
func (Item) StringValue ¶ added in v0.1.1
type LoadMethod ¶
type LoadMethod int
const ( LongFlag LoadMethod = iota ShortFlag EnvVar FileContentsLongFlag FileContentsShortFlag FileContentsDefaultLocation JsonFileLocationLongFlag JsonFileLocationShortFlag JsonFileDefaultLocation Error LoadMethodCount )