Simple .env
parser and loader for VLang projects.
v install TheBoringDude.venv
Loads the variables configured from your .env
file in your root project and adds them to the os.environ
import theboringdude.venv
import os
fn main() {
// run first the function
// if you want to have some configurations, use `venv.load_env_conf(LoaderConfig)`
venv.load_env()
// if you want to overwrite the variables
// use `venv.load_env(overwrite: true)`
// you can also just use `venv.load_env({})`
// this will default to true
// you can now access your variables
// from the `.env` file
println(os.getenv('My_VARIABLE'))
}
- Loads
.env
file using the default configurations.
-
Loads
.env
file with configurations.LoaderConfig
pub struct LoaderConfig { overwrite bool = true // custom default to true uppercase bool = true // convert env keys to uppercase }
// you can use venv's custom getenv to automatically convert vars
// to their respective vars
println(venv.getenv_bool("BOOL")) // bool env var value
println(venv.getenv_int("NUM")) // int env var value
println(venv.getenv_float("FLOAT")) // float env var value
I do not want to complicate a simple utility. It just parses the common .env
structure like, ..
# this is some comment
// you can do anything
#### but if `=` is detected, the line will be parsed
HELLO=WORLD