Documentation ¶
Index ¶
- func ClearTempDir()
- func CopyRef[T any](value T) *T
- func ElementType(initial reflect.Type) (et reflect.Type)
- func EnvironmentPreservesCase() bool
- func MustGetTempDir() string
- func NilOr[T comparable](value *T, expected T) bool
- func NotNilAnd[T comparable](value *T, expected T) bool
- func TempDir() (string, error)
- func UnpackValue(value reflect.Value) (v reflect.Value, isNil bool)
- type Environment
- func (e *Environment) Find(name string) (originalName, value string, ok bool)
- func (e *Environment) FoldedNames() (names []string)
- func (e *Environment) Get(name string) (value string)
- func (e *Environment) Has(name string) (found bool)
- func (e *Environment) Names() (names []string)
- func (e *Environment) Put(name, value string)
- func (e *Environment) Remove(name string)
- func (e *Environment) ResolveName(name string) string
- func (e *Environment) SetValues(values ...string)
- func (e *Environment) Values() (values []string)
- func (e *Environment) ValuesAsMap() (m map[string]string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearTempDir ¶
func ClearTempDir()
ClearTempDir removes the temporary directory (if present) and resets the state. This is not safe for concurrent use and is meant for cleanup in unit tests only.
func ElementType ¶
ElementType returns the type after removing all reflect.Array, reflect.Chan, reflect.Map, reflect.Pointer and reflect.Slice
func EnvironmentPreservesCase ¶ added in v0.23.0
func EnvironmentPreservesCase() bool
EnvironmentPreservesCase returns true if environment variables are case sensitive (all OS except Windows)
func MustGetTempDir ¶
func MustGetTempDir() string
MustGetTempDir returns the dir from TempDir or panics if an error occurred
func NilOr ¶
func NilOr[T comparable](value *T, expected T) bool
NilOr returns true if value is nil or expected
func NotNilAnd ¶
func NotNilAnd[T comparable](value *T, expected T) bool
NotNilAnd returns true if value is not nil and expected
Types ¶
type Environment ¶ added in v0.23.0
type Environment struct {
// contains filtered or unexported fields
}
Environment manages a set of environment variables
func NewDefaultEnvironment ¶ added in v0.23.0
func NewDefaultEnvironment(values ...string) *Environment
NewDefaultEnvironment creates Environment with OS defaults for preserveCase and the specified initial values
func NewEnvironment ¶ added in v0.23.0
func NewEnvironment(preserveCase bool, values ...string) *Environment
NewEnvironment creates Environment with optional preserveCase and the specified initial values
func NewFoldingEnvironment ¶ added in v0.23.0
func NewFoldingEnvironment(values ...string) *Environment
NewFoldingEnvironment creates an Environment that folds the case of variable names
func (*Environment) Find ¶ added in v0.23.0
func (e *Environment) Find(name string) (originalName, value string, ok bool)
Find returns the variable's original name, its value and ok when the variable exists
func (*Environment) FoldedNames ¶ added in v0.23.0
func (e *Environment) FoldedNames() (names []string)
FoldedNames returns all environment variables names (case depends on preserveCase)
func (*Environment) Get ¶ added in v0.23.0
func (e *Environment) Get(name string) (value string)
Get returns the variable value, possibly an empty string when the variable is unset or empty.
func (*Environment) Has ¶ added in v0.23.0
func (e *Environment) Has(name string) (found bool)
Has returns true as the variable with name is set.
func (*Environment) Names ¶ added in v0.23.0
func (e *Environment) Names() (names []string)
Names returns all environment variables names (case is preserved as inserted)
func (*Environment) Put ¶ added in v0.23.0
func (e *Environment) Put(name, value string)
Put sets a single name and value pair
func (*Environment) Remove ¶ added in v0.23.0
func (e *Environment) Remove(name string)
Remove deletes the named env variable
func (*Environment) ResolveName ¶ added in v0.23.0
func (e *Environment) ResolveName(name string) string
ResolveName resolves the specified name to the actual variable name if case folding applies (preserveCase is false)
func (*Environment) SetValues ¶ added in v0.23.0
func (e *Environment) SetValues(values ...string)
SetValues sets one or more values of the format NAME=VALUE
func (*Environment) Values ¶ added in v0.23.0
func (e *Environment) Values() (values []string)
Values returns all environment variables as NAME=VALUE lines (case is preserved as inserted)
func (*Environment) ValuesAsMap ¶ added in v0.23.0
func (e *Environment) ValuesAsMap() (m map[string]string)
ValuesAsMap returns all environment variables as name & value map