Documentation ¶
Overview ¶
Package env makes it possible to track use of environment variables within a procress in order to generate documentation for these uses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoolVar ¶
type BoolVar struct {
Var
}
BoolVar represents a single boolean environment variable.
func RegisterBoolVar ¶
RegisterBoolVar registers a new boolean environment variable.
func (BoolVar) Get ¶
Get retrieves the value of the environment variable. It returns the value, which will be the default if the variable is not present. To distinguish between an empty value and an unset value, use Lookup.
type DurationVar ¶
type DurationVar struct {
Var
}
DurationVar represents a single duration environment variable.
func RegisterDurationVar ¶
func RegisterDurationVar(name string, defaultValue time.Duration, description string) DurationVar
RegisterDurationVar registers a new duration environment variable.
func (DurationVar) Get ¶
func (v DurationVar) Get() time.Duration
Get retrieves the value of the environment variable. It returns the value, which will be the default if the variable is not present. To distinguish between an empty value and an unset value, use Lookup.
func (DurationVar) Lookup ¶
func (v DurationVar) Lookup() (time.Duration, bool)
Lookup retrieves the value of the environment variable. If the variable is present in the environment the value (which may be empty) is returned and the boolean is true. Otherwise the returned value will be the default and the boolean will be false.
type FloatVar ¶
type FloatVar struct {
Var
}
FloatVar represents a single floating-point environment variable.
func RegisterFloatVar ¶
RegisterFloatVar registers a new floating-point environment variable.
func (FloatVar) Get ¶
Get retrieves the value of the environment variable. It returns the value, which will be the default if the variable is not present. To distinguish between an empty value and an unset value, use Lookup.
type GenericVar ¶
func Register ¶
func Register[T Parseable](name string, defaultValue T, description string) GenericVar[T]
func (GenericVar[T]) Get ¶
func (v GenericVar[T]) Get() T
Get retrieves the value of the environment variable. It returns the value, which will be the default if the variable is not present. To distinguish between an empty value and an unset value, use Lookup.
func (GenericVar[T]) GetName ¶
func (v GenericVar[T]) GetName() string
func (GenericVar[T]) IsSet ¶
func (v GenericVar[T]) IsSet() bool
func (GenericVar[T]) Lookup ¶
func (v GenericVar[T]) Lookup() (T, bool)
Lookup retrieves the value of the environment variable. If the variable is present in the environment the value (which may be empty) is returned and the boolean is true. Otherwise the returned value will be the default and the boolean will be false.
type IntVar ¶
type IntVar struct {
Var
}
IntVar represents a single integer environment variable.
func RegisterIntVar ¶
RegisterIntVar registers a new integer environment variable.
func (IntVar) Get ¶
Get retrieves the value of the environment variable. It returns the value, which will be the default if the variable is not present. To distinguish between an empty value and an unset value, use Lookup.
type Parseable ¶
type Parseable interface { comparable }
type StringVar ¶
type StringVar struct {
Var
}
StringVar represents a single string environment variable.
func RegisterStringVar ¶
RegisterStringVar registers a new string environment variable.
func (StringVar) Get ¶
Get retrieves the value of the environment variable. It returns the value, which will be the default if the variable is not present. To distinguish between an empty value and an unset value, use Lookup.
type Var ¶
type Var struct { // The name of the environment variable. Name string // The optional default value of the environment variable. DefaultValue string // Description of the environment variable's purpose. Description string // Hide the existence of this variable when outputting usage information. Hidden bool // Mark this variable as deprecated when generating usage information. Deprecated bool // The type of the variable's value Type VarType // The underlying Go type of the variable GoType string }
Var describes a single environment variable
func VarDescriptions ¶
func VarDescriptions() []Var
VarDescriptions returns a description of this process' environment variables, sorted by name.
type VariableInfo ¶
VariableInfo provides generic information about a variable. All Variables implement this interface. This is largely to workaround lack of covariance in Go.