env

package
v3.0.0-...-ac50d8e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBoolFromEnv

func ParseBoolFromEnv(envVar string, defaultValue bool) bool

ParseBoolFromEnv retrieves a boolean value from given environment envVar. Returns default value if envVar is not set.

nolinit:unparam

func ParseDurationFromEnv

func ParseDurationFromEnv(env string, defaultValue, min, max time.Duration) time.Duration

Helper function to parse a time duration from an environment variable. Returns a default if env is not set, is not parseable to a duration, exceeds max (if max is greater than 0) or is less than min.

nolinit:unparam

func ParseFloat64FromEnv

func ParseFloat64FromEnv(env string, defaultValue, min, max float64) float64

Helper function to parse a float64 from an environment variable. Returns a default if env is not set, is not parseable to a number, exceeds max (if max is greater than 0) or is less than min (and min is greater than 0).

func ParseFloatFromEnv

func ParseFloatFromEnv(env string, defaultValue, min, max float32) float32

Helper function to parse a float32 from an environment variable. Returns a default if env is not set, is not parseable to a number, exceeds max (if max is greater than 0) or is less than min (and min is greater than 0).

func ParseInt64FromEnv

func ParseInt64FromEnv(env string, defaultValue, min, max int64) int64

Helper function to parse a int64 from an environment variable. Returns a default if env is not set, is not parseable to a number, exceeds max (if max is greater than 0) or is less than min.

func ParseNumFromEnv

func ParseNumFromEnv(env string, defaultValue, min, max int) int

Helper function to parse a number from an environment variable. Returns a default if env is not set, is not parseable to a number, exceeds max (if max is greater than 0) or is less than min.

func ParseStringToStringFromEnv

func ParseStringToStringFromEnv(envVar string, defaultValue map[string]string, separator string) map[string]string

ParseStringToStringVar parses given value from the environment as a map of string. Returns default value if envVar is not set.

func StringFromEnv

func StringFromEnv(env string, defaultValue string, opts ...StringFromEnvOpts) string

func StringsFromEnv

func StringsFromEnv(env string, defaultValue []string, separator string) []string

StringsFromEnv parses given value from the environment as a list of strings, using separator as the delimeter, and returns them as a slice. The strings in the returned slice will have leading and trailing white space removed.

Types

type StringFromEnvOpts

type StringFromEnvOpts struct {
	// AllowEmpty allows the value to be empty as long as the environment variable is set.
	AllowEmpty bool
}

Jump to

Keyboard shortcuts

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