env

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilLoader                        = errors.New("loader cannot be nil")
	ErrEnvironmentVariableNotFound      = "environment variable not found: %v"
	ErrFailedToLoadEnvironmentVariables = errors.New("failed to load environment variables")
	ErrInvalidDuration                  = "invalid key '%v' duration value: %v"
	ErrInvalidInteger                   = "invalid key '%v' integer value: %v"
)

Functions

This section is empty.

Types

type DefaultLoader added in v0.2.4

type DefaultLoader struct{}

DefaultLoader struct

func NewDefaultLoader added in v0.2.4

func NewDefaultLoader(loadFn func() error) (*DefaultLoader, error)

NewDefaultLoader creates a new default environment variable loader

func (*DefaultLoader) LoadDurationVariable added in v0.2.4

func (d *DefaultLoader) LoadDurationVariable(key string) (
	duration time.Duration,
	err error,
)

LoadDurationVariable load duration variable from environment variables

func (*DefaultLoader) LoadIntVariable added in v0.2.4

func (d *DefaultLoader) LoadIntVariable(key string) (value int, err error)

LoadIntVariable load integer variable from environment variables

func (*DefaultLoader) LoadSecondsVariable added in v0.2.4

func (d *DefaultLoader) LoadSecondsVariable(key string) (
	seconds float64,
	err error,
)

LoadSecondsVariable load duration variable in seconds from environment variables

func (*DefaultLoader) LoadVariable added in v0.2.4

func (d *DefaultLoader) LoadVariable(key string) (uri string, err error)

LoadVariable load variable from environment variables

type Loader added in v0.2.4

type Loader interface {
	LoadVariable(key string) (uri string, err error)
	LoadDurationVariable(key string) (duration time.Duration, err error)
	LoadSecondsVariable(key string) (seconds float64, err error)
	LoadIntVariable(key string) (value int, err error)
}

Loader interface for loading environment variables

type Logger

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

Logger is the environment logger

func NewLogger

func NewLogger(logger gologger.Logger) (*Logger, error)

NewLogger creates a new environment logger

func (*Logger) EnvironmentVariableLoaded

func (l *Logger) EnvironmentVariableLoaded(variablesName ...string)

EnvironmentVariableLoaded logs a message when an environment variable is loaded

Jump to

Keyboard shortcuts

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