env

package
v2.12.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBoolFromEnv added in v2.1.0

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 added in v2.10.0

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).

nolint:unparam

func ParseFloatFromEnv added in v2.3.0

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).

nolint:unparam

func ParseInt64FromEnv added in v2.2.0

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.

nolint:unparam

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.

nolint:unparam

func ParseStringToStringFromEnv added in v2.10.0

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 added in v2.4.4

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 added in v2.8.11

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