Documentation
¶
Overview ¶
Package env is a codegen-first environment variable parser for Go. Use cmd/envgen to generate type-specific loaders with zero runtime reflection.
Index ¶
- Constants
- func AppendParse(errs *[]FieldError, field, key, value string, parseErr error)
- func AppendRequired(errs *[]FieldError, field, key string)
- func NewError(fields []FieldError) error
- func ParseBool(s string) (bool, error)
- func ParseDuration(s string) (time.Duration, error)
- func ParseFloat32(s string) (float32, error)
- func ParseFloat64(s string) (float64, error)
- func ParseInt(s string) (int, error)
- func ParseInt8(s string) (int8, error)
- func ParseInt16(s string) (int16, error)
- func ParseInt32(s string) (int32, error)
- func ParseInt64(s string) (int64, error)
- func ParseIntSlice(s, sep string) ([]int, error)
- func ParseString(s string) (string, error)
- func ParseStringMap(s, sep, kvSep string) (map[string]string, error)
- func ParseStringSlice(s, sep string) ([]string, error)
- func ParseUint(s string) (uint, error)
- func ParseUint8(s string) (uint8, error)
- func ParseUint16(s string) (uint16, error)
- func ParseUint32(s string) (uint32, error)
- func ParseUint64(s string) (uint64, error)
- func ResetSnapshot()
- type EnvSnapshot
- type Error
- type FieldError
- type Unmarshaler
Constants ¶
View Source
const SensitiveMask = "***"
SensitiveMask replaces sensitive fields in generated Masked() output.
Variables ¶
This section is empty.
Functions ¶
func AppendParse ¶
func AppendParse(errs *[]FieldError, field, key, value string, parseErr error)
func AppendRequired ¶
func AppendRequired(errs *[]FieldError, field, key string)
func ParseFloat32 ¶
func ParseFloat64 ¶
func ParseInt16 ¶
func ParseInt32 ¶
func ParseInt64 ¶
func ParseIntSlice ¶
func ParseString ¶
func ParseStringSlice ¶
func ParseUint8 ¶
func ParseUint16 ¶
func ParseUint32 ¶
func ParseUint64 ¶
func ResetSnapshot ¶
func ResetSnapshot()
ResetSnapshot rebuilds the cached snapshot. Intended for tests.
Types ¶
type EnvSnapshot ¶
type EnvSnapshot struct {
// contains filtered or unexported fields
}
EnvSnapshot holds an indexed view of environment variables.
func FromEnviron ¶
func FromEnviron(environ []string) *EnvSnapshot
func FromMap ¶
func FromMap(vars map[string]string) *EnvSnapshot
func Snapshot ¶
func Snapshot() *EnvSnapshot
Snapshot returns a cached process environment index. The index is built once from os.Environ() until ResetSnapshot is called.
func (*EnvSnapshot) Len ¶
func (s *EnvSnapshot) Len() int
type Error ¶
type Error struct {
Fields []FieldError
// contains filtered or unexported fields
}
Error collects every field error from one parse pass.
type FieldError ¶
FieldError is a single field-level configuration error.
func (FieldError) Error ¶
func (e FieldError) Error() string
type Unmarshaler ¶
Unmarshaler parses a custom type from a raw environment value.
Click to show internal directories.
Click to hide internal directories.