osext

package
v5.31.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Env

func Env[T EnvDefaults](key string, defaultValue T) T

Env retrieves the value of the environment variable named by the key.

If the variable is not set, or if the conversion fails due to incorrect value, a default value is returned.

func GetEnv

func GetEnv[T EnvDefaults](key string) Option[T]

GetEnv retrieves the value of the environment variable named by the key.

If the variable is not set, or if the conversion fails it returns `None`, otherwise `Some`.

func LookupEnv

func LookupEnv[T EnvDefaults](key string) Result[Option[T], error]

LookupEnv retrieves the value of the environment variable named by the key.

If the variable is not present it returns Ok(None) If the variable is present and conversion is successful, the value Ok(Some) is returned If the variable is present and conversion fails it returns Err(error)

Types

type EnvDefaults

type EnvDefaults interface {
	constraintsext.Number | ~string
}

EnvDefaults interface defines the supported types that can be used for environment variables conversions.

Jump to

Keyboard shortcuts

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