internal

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package internal provides internal implementation logic for environment variables parsing.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotSet is an error that is returned when the environment variable is not set.
	ErrNotSet = errors.New("not set")
	// ErrInvalidValue is an error that is returned when the environment variable is not valid.
	ErrInvalidValue = errors.New("invalid value")
)

Functions

This section is empty.

Types

type Bool added in v1.9.0

type Bool interface {
	bool | []bool
}

Bool is a constraint for bool and slice of bool.

type Complex added in v1.9.0

type Complex = constraints.Complex

Complex is a constraint for complex and slice of complex.

type ComplexSlice added in v1.11.0

type ComplexSlice interface {
	[]complex64 | []complex128
}

ComplexSlice is a constraint for slice of complex.

type EnvParsable

type EnvParsable interface {
	String | Number | NumberSlice | Time | Bool | URL | IP | Complex | ComplexSlice
}

EnvParsable is a constraint for types that can be parsed from environment variable.

type EnvParser

type EnvParser interface {
	// ParseEnv parses environment variable by key and returns value.
	ParseEnv(key string, options Parameters) (any, error)
}

EnvParser interface for parsing environment variables.

func NewEnvParser

func NewEnvParser(v any) EnvParser

NewEnvParser is a constructor for EnvParser.

type Float

type Float = constraints.Float

Float is a constraint for float and slice of floats.

type FloatSlice added in v1.11.0

type FloatSlice interface {
	[]float32 | []float64
}

FloatSlice is a constraint for slice of floats.

type IP added in v1.9.0

type IP interface {
	net.IP | []net.IP
}

IP is a constraint for net.IP and slice of net.IP.

type Int

type Int = constraints.Signed

Int is a constraint for integer and slice of integers.

type IntSlice added in v1.11.0

type IntSlice interface {
	[]int | []int8 | []int16 | []int32 | []int64
}

IntSlice is a constraint for slice of integers.

type Number added in v1.11.0

type Number interface {
	Int | Float | Uint
}

Number is a constraint for integer, float and unsigned integer.

type NumberSlice added in v1.11.0

type NumberSlice interface {
	IntSlice | FloatSlice | UintSlice
}

NumberSlice is a constraint for slice of integers, floats and unsigned integers.

type Parameters

type Parameters struct {
	Separator string
	Layout    string
}

Parameters is a struct for holding parameters for the parser. It is used to pass parameters to the parser. Separator is a separator for the environment variable that holds slice. Layout is a layout for the time.Time.

type String

type String interface {
	string | []string
}

String is a constraint for string and slice of strings.

type Time

type Time interface {
	time.Time | []time.Time | time.Duration | []time.Duration
}

Time is a constraint for time.Time and slice of time.Time.

type URL added in v1.9.0

type URL interface {
	url.URL | []url.URL
}

URL is a constraint for url.URL and slice of url.URL.

type Uint added in v1.6.0

type Uint = constraints.Unsigned

Uint is a constraint for unsigned integer and slice of unsigned integers.

type UintSlice added in v1.11.0

type UintSlice interface {
	[]uint | []uint8 | []uint16 | []uint32 | []uint64 | []uintptr
}

UintSlice is a constraint for slice of unsigned integers.

Jump to

Keyboard shortcuts

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