env

package
v1.5.12 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 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 Get

func Get(key string) (string, error)

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

func GetAll

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

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

func GetValOrDefault

func GetValOrDefault(key, defaultVal string) string

Same as Get, but with default value.

func Load

func Load(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 ParseBool

func ParseBool(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 ParseInt

func ParseInt(key string) (int, error)

Gets and parses key's value to int.

func ParseTimeDuration

func ParseTimeDuration(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