config

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config provides typed accessors for environment variables with sensible defaults and panic-on-missing semantics.

For .env file loading, use the godotenv/autoload blank import in your main package:

import _ "github.com/joho/godotenv/autoload"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnvCSV

func GetEnvCSV(key string) []string

GetEnvCSV returns the environment variable named by key parsed as a comma-separated list, with surrounding whitespace trimmed and empty entries dropped. Returns nil when the variable is unset/empty or contains no non-empty entries.

func GetEnvOrDefault

func GetEnvOrDefault(key, def string) string

GetEnvOrDefault returns the value of the environment variable named by key, or def if the variable is unset or empty.

func GetEnvOrDefaultBool

func GetEnvOrDefaultBool(key string, def bool) bool

GetEnvOrDefaultBool returns the environment variable as a bool, falling back to def if unset, empty, or not a valid boolean. Note: invalid values silently fall back to the default with no warning.

func GetEnvOrDefaultDuration

func GetEnvOrDefaultDuration(key string, def time.Duration) time.Duration

GetEnvOrDefaultDuration returns the environment variable as a time.Duration, falling back to def if unset, empty, or not a valid duration string. Note: invalid values silently fall back to the default with no warning.

func GetEnvOrDefaultInt

func GetEnvOrDefaultInt(key string, def int) int

GetEnvOrDefaultInt returns the environment variable as an int, falling back to def if unset, empty, or not a valid integer. Note: invalid values silently fall back to the default with no warning.

func GetEnvOrPanic

func GetEnvOrPanic(key string) string

GetEnvOrPanic returns the value of the environment variable named by key. It panics if the variable is unset or empty.

func ParseBaseURL

func ParseBaseURL(raw string) (origin, hostname string, err error)

ParseBaseURL validates a raw base URL string and returns the origin (scheme://host, including port if present) and the hostname (without port). An empty input is valid and returns zero values (optional in dev).

Types

This section is empty.

Jump to

Keyboard shortcuts

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