Documentation
¶
Overview ¶
gotenv is a general-purpose package to load environment variables from files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadEnv ¶
func LoadEnv(opts ...LoadOptions) (map[string]string, error)
LoadEnv loads environment variables from a given file name specified in the given optional parameter opts. Default values are given by DefaultLoadOptions.
This function returns a map of the environment variables that were added by the environment file, and an error if one occurred. Environment variables can also be accessed normally using os.Getenv.
func LoadEnvFromFS ¶
LoadEnvFromFS loads environment variables from a given file name specified in the given optional parameter opts, using the given file system fsys. Default values for opts are given by DefaultLoadOptions.
This function returns a map of the environment variables that were added by the environment file, and an error if one occurred. Environment variables can also be accessed normally using os.Getenv.
func LoadEnvFromReader ¶
func LoadEnvFromReader(reader io.Reader, opts ...LoadEnvFromReaderOptions) (map[string]string, error)
LoadEnvFromReader loads environment variables from a given io.Reader. Default values for opts are given by DefaultLoadEnvFromReaderOptions.
This function returns a map of the environment variables that were added by the environment file, and an error if one occurred. Environment variables can also be accessed normally using os.Getenv.
Types ¶
type LoadEnvFromReaderOptions ¶
type LoadEnvFromReaderOptions struct {
OverrideExistingVars bool
}
LoadEnvFromReaderOptions is a struct that contains options for the LoadEnvFromReader function.
func DefaultLoadEnvFromReaderOptions ¶
func DefaultLoadEnvFromReaderOptions() LoadEnvFromReaderOptions
DefaultLoadEnvFromReaderOptions returns the default options for the LoadEnvFromReader function. The default options are:
OverrideExistingVars: true
type LoadOptions ¶
LoadOptions is a struct that contains options for the LoadEnv and LoadEnvFromFS functions.
func DefaultLoadOptions ¶
func DefaultLoadOptions() LoadOptions
DefaultLoadOptions returns the default options for the LoadEnv and LoadEnvFromFS functions. The default options are:
OverrideExistingVars: true FileName: ".env"