config

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolParser

func BoolParser(value string) (bool, error)

BoolParser is a parsing function for LoadEnv, that returns the boolean equivalent of the variable. For more information about supported value, refer to the documentation of strconv.ParseBool.

func DurationParser

func DurationParser(value string) (time.Duration, error)

DurationParser is a parsing function for LoadEnv, that returns the time.Duration representation of the variable. For more information about supported value, refer to the documentation of time.ParseDuration.

func EnumParser

func EnumParser[T comparable](parser func(string) (T, error), allow ...T) func(string) (T, error)

func Float32Parser

func Float32Parser(value string) (float32, error)

Float32Parser is a parsing function for LoadEnv, that returns the float32 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseFloat.

func Float64Parser

func Float64Parser(value string) (float64, error)

Float64Parser is a parsing function for LoadEnv, that returns the float64 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseFloat.

func Int8Parser

func Int8Parser(value string) (int8, error)

Int8Parser is a parsing function for LoadEnv, that returns the int8 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseInt.

func Int16Parser

func Int16Parser(value string) (int16, error)

Int16Parser is a parsing function for LoadEnv, that returns the int16 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseInt.

func Int32Parser

func Int32Parser(value string) (int32, error)

Int32Parser is a parsing function for LoadEnv, that returns the int32 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseInt.

func Int64Parser

func Int64Parser(value string) (int64, error)

Int64Parser is a parsing function for LoadEnv, that returns the int64 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseInt.

func IntParser

func IntParser(value string) (int, error)

IntParser is a parsing function for LoadEnv, that returns the int representation of the variable. For more information about supported value, refer to the documentation of strconv.Atoi.

func JSONMapParser

func JSONMapParser(value string) (map[string]any, error)

JSONMapParser is a parsing function for LoadEnv, that returns the map[string]any representation of the variable. The parser expects the value to be a valid JSON object.

func JSONSliceParser

func JSONSliceParser(value string) ([]any, error)

JSONSliceParser is a parsing function for LoadEnv, that returns the []any representation of the variable. The parser expects the value to be a valid JSON array.

func LoadEnv

func LoadEnv[T any](value string, fallback T, parser func(string) (T, error)) T

LoadEnv cast an environment variable to a native Go type, using the provided Parser function. If parsing fails, the fallback value is returned.

func Must

func Must[T any](value T, err error) T

Must automatically panics if the error is not nil.

func MustUnmarshal

func MustUnmarshal[T any](unmarshal func([]byte, any) error, src []byte) T

MustUnmarshal is a utility function that panics if the unmarshal operation fails.

func SliceParser

func SliceParser[T any](parser func(string) (T, error)) func(string) ([]T, error)

SliceParser is a parsing function for LoadEnv, that returns a slice of values of type T. The parser accepts a sub-parser to define the type of T.

func StringParser

func StringParser(value string) (string, error)

StringParser is a parsing function for LoadEnv, that returns the string content of the variable, as-is.

func TimeParser

func TimeParser(value string) (time.Time, error)

TimeParser is a parsing function for LoadEnv, that returns the time.Time representation of the variable. The parser expects the time to be in time.RFC3339 format. For more information about supported value, refer to the documentation of time.Parse.

func Uint8Parser

func Uint8Parser(value string) (uint8, error)

Uint8Parser is a parsing function for LoadEnv, that returns the uint8 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseUint.

func Uint16Parser

func Uint16Parser(value string) (uint16, error)

Uint16Parser is a parsing function for LoadEnv, that returns the uint16 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseUint.

func Uint32Parser

func Uint32Parser(value string) (uint32, error)

Uint32Parser is a parsing function for LoadEnv, that returns the uint32 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseUint.

func Uint64Parser

func Uint64Parser(value string) (uint64, error)

Uint64Parser is a parsing function for LoadEnv, that returns the uint64 representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseUint.

func UintParser

func UintParser(value string) (uint, error)

UintParser is a parsing function for LoadEnv, that returns the uint representation of the variable. For more information about supported value, refer to the documentation of strconv.ParseUint.

Types

This section is empty.

Jump to

Keyboard shortcuts

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