env

package
v0.16.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// LogLevel is the environment variable name for the log level.
	LogLevel = "LOG_LEVEL"

	DevLogLevel  = "dev"
	TestLogLevel = "test"
	ProdLogLevel = "prod"
)

Variables

This section is empty.

Functions

func GetLogLevel added in v0.12.1

func GetLogLevel() string

GetLogLevel reads LOG_LEVEL, falling back to dev when unset or unknown. A set-but-unknown value warns so the misconfiguration is not silent.

Types

type Map

type Map map[string]*Var

Map is a map of environment variables. We use a *Var as map values are not addressable, i.e. cannot be modified directly.

func (Map) SetEnv

func (m Map) SetEnv() error

SetEnv reads and sets the provided list of env vars based on the Map.

type Var

type Var struct {
	Value        string
	DefaultValue string
	IsInteger    bool
	IntValue     int
	IsBoolean    bool
	BooleanValue bool
	OneOf        []string
	Optional     bool // controls whether an env variable can be missing from the .env file but still declared
}

Var describes an environment variable and its configuration.

func NewLogLevelVar added in v0.16.0

func NewLogLevelVar() *Var

NewLogLevelVar returns the canonical LOG_LEVEL variable: defaults to dev. Deliberately not constrained via OneOf: an unknown value must not fail startup — consumers normalize it through GetLogLevel (warn + dev fallback), matching pre-OTel releases. Fresh *Var per call so Maps don't alias it.

Jump to

Keyboard shortcuts

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