env

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const EnvTag = "env"

Env var struct tag.

Variables

This section is empty.

Functions

func Unmarshaler

func Unmarshaler(dec *strdecode.Decoder) func(dst reflect.Value, typ reflect.Type, src string) error

Unmarshaler returns a default Decoder unmarshaling func implementation based on given strdecode.Decoder instance.

Types

type Flag

type Flag struct {
	// Key is the env flag key name.
	Key string

	// Value contains determined value string for this
	// flag, populated by the .Parse() function.
	Value *string
	// contains filtered or unexported fields
}

func NewFlag

func NewFlag(dst interface{}, key string, value string) Flag

NewFlag ...

type FlagSet

type FlagSet struct {
	// Flags should contain possible keys to be searched for when parsing env vars.
	Flags Flags

	// Unmarshal should unmarshal possible environment value into 'dst'.
	Unmarshal func(dst reflect.Value, typ reflect.Type, src string) error
}

func (*FlagSet) Bool

func (set *FlagSet) Bool(key string, value bool) *bool

func (*FlagSet) BoolVar

func (set *FlagSet) BoolVar(ptr *bool, key string, value bool)

func (*FlagSet) Bytes

func (set *FlagSet) Bytes(key string, value []byte) *[]byte

func (*FlagSet) BytesVar

func (set *FlagSet) BytesVar(ptr *[]byte, key string, value []byte)

func (*FlagSet) Float

func (set *FlagSet) Float(key string, value float64) *float64

func (*FlagSet) FloatVar

func (set *FlagSet) FloatVar(ptr *float64, key string, value float64)

func (*FlagSet) Int

func (set *FlagSet) Int(key string, value int) *int

func (*FlagSet) Int64

func (set *FlagSet) Int64(key string, value int64) *int64

func (*FlagSet) Int64Var

func (set *FlagSet) Int64Var(ptr *int64, key string, value int64)

func (*FlagSet) IntVar

func (set *FlagSet) IntVar(ptr *int, key string, value int)

func (*FlagSet) Parse

func (set *FlagSet) Parse(env []string) error

Parse ... will parse value strings from env vars slice, storing in the Decoder before call to Decode().

func (*FlagSet) ParseFile

func (set *FlagSet) ParseFile(src io.Reader) error

ParseFile ...

func (*FlagSet) String

func (set *FlagSet) String(key string, value string) *string

func (*FlagSet) StringVar

func (set *FlagSet) StringVar(ptr *string, key string, value string)

func (*FlagSet) StructFields

func (set *FlagSet) StructFields(dst interface{})

func (*FlagSet) Uint

func (set *FlagSet) Uint(key string, value uint) *uint

func (*FlagSet) Uint64

func (set *FlagSet) Uint64(key string, value uint64) *uint64

func (*FlagSet) Uint64Var

func (set *FlagSet) Uint64Var(ptr *uint64, key string, value uint64)

func (*FlagSet) UintVar

func (set *FlagSet) UintVar(ptr *uint, key string, value uint)

func (*FlagSet) Validate

func (set *FlagSet) Validate() error

Validate will check over receiving Flags for valid flag keys and conflicts.

func (*FlagSet) Var

func (set *FlagSet) Var(dst interface{}, key, value string)

type Flags

type Flags []Flag

Flags provides helpful methods for a slice of flags.

func (Flags) AppendFormat

func (f Flags) AppendFormat(b []byte) []byte

AppendFormat will append a new-line separated string representation of Flags to b.

func (Flags) Get

func (f Flags) Get(key string) *Flag

Get will fetch the flag with matching env key, or return nil.

func (Flags) Sort

func (f Flags) Sort()

Sort will alphabetically sort receiving Flags.

func (Flags) String

func (f Flags) String() string

String will return a new-line separated string representation of Flags.

type InvalidFlagError

type InvalidFlagError struct {
	Key string
	Msg string
}

InvalidFlagError encapsulates error information regarding an invalid flag when calling env.Flags{}.Validate().

func (*InvalidFlagError) Error

func (err *InvalidFlagError) Error() string

Jump to

Keyboard shortcuts

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