env

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key, defaultValue string) string

Get retrieves an environment variable value, returning defaultValue if the variable is not set or is set to the empty string. To distinguish "not set" from "set to empty", use Lookup or Has.

func GetBool

func GetBool(key string, defaultValue bool) bool

GetBool retrieves an environment variable as a boolean, returning defaultValue if not set or invalid

func GetDuration

func GetDuration(key string, defaultValue time.Duration) time.Duration

GetDuration retrieves an environment variable as a duration, returning defaultValue if not set or invalid

func GetFloat64

func GetFloat64(key string, defaultValue float64) float64

GetFloat64 retrieves an environment variable as a float64, returning defaultValue if not set or invalid

func GetInt

func GetInt(key string, defaultValue int) int

GetInt retrieves an environment variable as an integer, returning defaultValue if not set or invalid

func GetInt64

func GetInt64(key string, defaultValue int64) int64

GetInt64 retrieves an environment variable as an int64, returning defaultValue if not set or invalid

func GetStringSlice

func GetStringSlice(key string, defaultValue []string, sep string) []string

GetStringSlice retrieves a delimited environment variable as a string slice. Returns defaultValue if not set or no valid items found.

func GetTrimmed

func GetTrimmed(key, defaultValue string) string

GetTrimmed retrieves a trimmed environment variable value, returning defaultValue if not set or empty

func GetUint

func GetUint(key string, defaultValue uint) uint

GetUint retrieves an environment variable as a uint, returning defaultValue if not set or invalid

func GetUint64

func GetUint64(key string, defaultValue uint64) uint64

GetUint64 retrieves an environment variable as a uint64, returning defaultValue if not set or invalid

func Has added in v0.2.0

func Has(key string) bool

Has checks if an environment variable is set (even if empty). Returns true if the variable exists, false otherwise.

func Lookup added in v0.2.0

func Lookup(key string) (string, bool)

Lookup retrieves an environment variable value and a boolean indicating whether it was set. This is useful for distinguishing between "not set" and "set to empty string". Returns (value, true) if the variable exists, (empty string, false) otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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