envutil

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandEnvArgs added in v0.2.15

func ExpandEnvArgs(args []string) []string

ExpandEnvArgs expands Docker -e flags that reference environment variables. Converts "-e VAR_NAME" to "-e VAR_NAME=value" by reading from the process environment. If the variable is not set, the flag is passed through unchanged.

func GetEnvBool

func GetEnvBool(envKey string, defaultValue bool) bool

GetEnvBool returns the boolean value of the environment variable specified by envKey. If the environment variable is not set or is empty, it returns the defaultValue. Truthy values (case-insensitive): "1", "true", "yes", "on" Falsy values (case-insensitive): "0", "false", "no", "off" Any other value returns the defaultValue.

func GetEnvDuration added in v0.2.13

func GetEnvDuration(envKey string, defaultValue time.Duration) time.Duration

GetEnvDuration returns the time.Duration value of the environment variable specified by envKey. If the environment variable is not set, is empty, or cannot be parsed by time.ParseDuration, it returns the defaultValue. Accepts any string valid for time.ParseDuration (e.g. "2h", "30m", "90s").

func GetEnvInt

func GetEnvInt(envKey string, defaultValue int) int

GetEnvInt returns the integer value of the environment variable specified by envKey. If the environment variable is not set, is empty, cannot be parsed as an integer, or is not positive (> 0), it returns the defaultValue. This function validates that the value is a positive integer.

func GetEnvString

func GetEnvString(envKey, defaultValue string) string

GetEnvString returns the value of the environment variable specified by envKey. If the environment variable is not set or is empty, it returns the defaultValue.

Types

This section is empty.

Jump to

Keyboard shortcuts

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