19 lines
804 B
Go
19 lines
804 B
Go
// Package env provides utilities for reading environment variables with type safety
|
|
// and default values. It supports common Go types including strings, integers (all sizes),
|
|
// unsigned integers (all sizes), booleans, and time.Duration values.
|
|
//
|
|
// The package follows a simple pattern where each function takes a key name and a
|
|
// default value, returning the parsed environment variable or the default if the
|
|
// variable is not set or cannot be parsed.
|
|
//
|
|
// Example usage:
|
|
//
|
|
// port := env.Int("PORT", 8080)
|
|
// debug := env.Bool("DEBUG", false)
|
|
// timeout := env.Duration("TIMEOUT", 30*time.Second)
|
|
//
|
|
// All functions gracefully handle missing environment variables by returning the
|
|
// provided default value. They also handle parsing errors by falling back to the
|
|
// default value.
|
|
package env
|