dotenv_gleam
Types
An error that can occur when loading environment variables from a .env
file.
pub type DotEnvError {
ErrorReadingEnvFile(simplifile.FileError)
}
Constructors
-
ErrorReadingEnvFile(simplifile.FileError)
Functions
pub fn config() -> Result(Nil, DotEnvError)
Tries to load environment variables from a .env
file in the current
working directory.
this function returns a result with the error if it’s not possible to read
the file.
Examples
> let assert Ok(Nil) = config()
> envoy.get("TEST")
Ok("test")
> use _ <- result.try(config())
> envoy.get("TEST")
Ok("test")
pub fn config_with(file: String) -> Result(Nil, DotEnvError)
Tries to load environment variables from a file specified in the current working directory. this function returns a result with the error if it’s not possible to read the file.
Examples
> let assert Ok(Nil) = config_with("path/to/.env")
> envoy.get("TEST")
Ok("test")
> use _ <- result.try(config_with("path/to/.env"))
> envoy.get("TEST")
Ok("test")