env

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimplifyPrefix

func SimplifyPrefix(prefix string) string

SimplifyPrefix This method trim right all _ ang - symbols and spaces left and right.

Types

type Extractor

type Extractor struct {
	// contains filtered or unexported fields
}

func NewExtractor

func NewExtractor(prefix string, lookupFunc LookupFunc) *Extractor

NewExtractor utils for extract env and pass to destination by default extractor use _ for separate prefix and env name if need we use WithPrefixSeparator method for set your own or set to empty by default slice string extractor split env string by , symbol if need we use WithSliceSeparator method for set your own slice separator

func NewOsExtractor

func NewOsExtractor(prefix string) *Extractor

NewOsExtractor create extractor with os.LookupEnv lookup function

func (*Extractor) AddEnvToUsage

func (e *Extractor) AddEnvToUsage(usage string, envName string) string

func (*Extractor) Bool

func (e *Extractor) Bool(name string, destination *bool) bool

Bool trim spaces env and to lower value string lower value string "false" "no" "none" "0" interpreter as false returns that env is set

func (*Extractor) ExtractAll

func (e *Extractor) ExtractAll(vars []*Var) error

ExtractAll extract all envs from map if env present but have empty value set Var Present field to true you can process it if need ExtractAll found need type for Destination, but destination should be pointer Warning! if error returned some Destination can be set

func (*Extractor) ExtractAllVars

func (e *Extractor) ExtractAllVars(vars ...*Var) error

ExtractAllVars same as ExtractAll but can pass as variadic arguments

func (*Extractor) Int

func (e *Extractor) Int(name string, destination *int) (bool, error)

func (*Extractor) NameWithPrefix

func (e *Extractor) NameWithPrefix(name string) string

func (*Extractor) String

func (e *Extractor) String(name string, destination *string) bool

func (*Extractor) StringWithoutPrefix

func (e *Extractor) StringWithoutPrefix(name string, destination *string) bool

func (*Extractor) Strings

func (e *Extractor) Strings(name string, destination *[]string) bool

func (*Extractor) WithPrefixSeparator

func (e *Extractor) WithPrefixSeparator(s string) *Extractor

func (*Extractor) WithSliceSeparator

func (e *Extractor) WithSliceSeparator(s string) *Extractor

WithSliceSeparator set only not empty string

type LookupFunc

type LookupFunc func(name string) (string, bool)

type Var

type Var struct {
	Name        string
	Destination any
	Present     bool
}

func NewVar

func NewVar(name string, destination any) *Var

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL