Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Development env definition. Development string = "development" // Staging env definition. Staging = "staging" // Production env definition. Production = "production" )
Environment definitions.
View Source
const (
// AppEnvironmentKey is the key for the app environment, i.e. prod/dev
AppEnvironmentKey = "APP_ENV"
)
Common keys
Variables ¶
This section is empty.
Functions ¶
func GetOrError ¶
GetOrError will attempt to get the value from the environment variable and return an error if not available.
func IsDevelopment ¶
func IsDevelopment() bool
IsDevelopment returns whether we are running the app in development.
func IsProduction ¶
func IsProduction() bool
IsProduction returns whether we are running the app in production.
func ParseConfig ¶
ParseConfig loads the environment variables from the .env file and parses the environment variables into the provided struct. It returns an error if the .env file cannot be loaded or if the environment variables cannot be parsed.\
For example: type Config struct { Home string `env:"HOME"` Port int `env:"PORT" envDefault:"3000"` Password string `env:"PASSWORD,unset"` IsProduction bool `env:"PRODUCTION"` Duration time.Duration `env:"DURATION"` Hosts []string `env:"HOSTS" envSeparator:":"` TempFolder string `env:"TEMP_FOLDER,expand" envDefault:"${HOME}/tmp"` StringInts map[string]int `env:"MAP_STRING_INT"` }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.