dot_env/env

Functions

pub fn get(key: String) -> Result(String, String)

Get an environment variable (supports both Erlang and JavaScript targets)

Example:

import dot_env/env
import gleam/io
import gleam/result

env.get("MY_ENV_VAR")
|> result.unwrap("NOT SET")
|> io.println
pub fn get_bool(key: String) -> Result(Bool, String)

Get an environment variable as a boolean

pub fn get_int(key: String) -> Result(Int, String)

Get an environment variable as an integer

pub fn get_or(key: String, default: String) -> String

Get an environment variable or return a default value

pub fn set(key: String, value: String) -> Nil

Set an environment variable (supports both Erlang and JavaScript targets)

Example:

import dot_env/env

env.set("MY_ENV_VAR", "my value")
Search Document