env

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Dev     = "dev"
	Prod    = "prod"
	Staging = "staging"
)

Variables

This section is empty.

Functions

func GetAllEnvs added in v1.1.0

func GetAllEnvs(filenames ...string) (map[string]string, error)

A wrapper func around godotenv read func, handling errors more precisely.

func GetEnv

func GetEnv(key string) (string, error)

A wrapper func around os.Getenv, but handles error with more text.

func GetEnvOrDefault

func GetEnvOrDefault(key, defaultVal string) string

Same as GetEnv, but with default value.

func LoadEnv

func LoadEnv(filenames ...string) error

Loads environment variables from the given files. It is intented to be used in development mode. If in dev mode, make sure to load the env vars first, then call other funcs.

func ParseEnvBool

func ParseEnvBool(key string) (bool, error)

Gets key's value, calling GetEnv and parses to bool. Assumes it is in a specific format - text or a binary representation.

func ParseEnvInt

func ParseEnvInt(key string) (int, error)

Gets and parses key's value to int.

func ParseEnvTimeDuration

func ParseEnvTimeDuration(key string) (time.Duration, error)

Gets and parses key's value to duration.

Types

This section is empty.

Jump to

Keyboard shortcuts

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