dot_env

Package Version Hex Docs

dot_env is a port of the popular JavaScript dotenv package that helps you load environment variables from .env (or other) files.

This package may support other formats in the future but for now, supports the popular .env format

You can find the Javascript test here

Quick start

import dot_env
import dot_env/env
import gleam/io

pub fn main() {
   dot_env.load_with_opts(dot_env.Opts(path: "path/to/.env", debug: False, capitalize: False))
   // or `dot_env.load()` to load the `.env` file in the root path

   case env.get("MY_ENV_VAR") {
       Ok(value) -> io.println(value)
       Error(_) -> io.println("something went wrong")
   }

   Nil
}

Installation

gleam add dot_env

and its documentation can be found at https://hexdocs.pm/dot_env.

Search Document