read-dotenv-files

This repository contains small scripts as well as instructions to read .env files in several languages.

View the Project on GitHub Baelfire18/read-dotenv-files

Julia

  1. You’ll need a working Julia installation.
  2. You’ll need the DotEnv.jl package, installable using Pkg:
    Pkg.add("DotEnv")
    

    Or through the REPL by writing ] add DotEnv.

This packages includes a DotEnv.config function that loads a .env file into the global ENV dictionary, allowing the same access pattern as normal environment variables.

using DotEnv

DotEnv.config()

Which allows us to simply access environment variables directly:

db_name = ENV["DB_NAME"]
println(db_name)