Documentation ¶
Overview ¶
Package env provides functionality for loading environment variables.
The variables are primarily sourced from optional .env files located within the project directory. These .env files offer a convenient method for setting environment variables for both development and production.
The package features an AutoLoad function. AutoLoad is designed to automatically load environment variables from a default .env file.
Additionally, AutoLoad checks for the existence of .env.<ENV>.local and .env.local files, loading variables from them if they are found. This functionality allows for environment-specific variables to be set, thereby enhancing the flexibility of the environment configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoLoad ¶
AutoLoad loads the default .env file and the .env.local file if it exists. The default .env file is expected to be embedded in the binary, and provided as the defaultEnvContent argument.
It also loads the .env.<ENV>.local file if the ENV environment variable is set. If the ENV environment variable is not set, it defaults to "dev".
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader loads environment variables from a file.
func (*Loader) LoadOptional ¶
LoadOptional loads the environment variables from the given file. It ignores the file if it does not exist.