dotenv module for V
English / Japanese
vdotenv is a module to read environment variables from
.env
- Which loads env vars from a .env file.
- Existing environment variables can be overridden in the program
- Inspired by
https://github.com/joho/godotenv
.
Usage
Add your application configuration to your
.env
S3_BUCKET=YOURS3BUCKET
DYNAMODB_TABLE=YOURDYNAMODBTABLE
Then in your V app you can do something like
import os
import zztkm.vdotenv
fn main() {
// loads env vars from a .env file.
vdotenv.load()
s3_bucket := os.getenv('S3_BUCKET')
dynamodb_table := os.getenv('DYNAMODB_TABLE')
// ...
}
By default, load looks for a file called .env in your current working directory, but you can also specify the file as follows:
vdotenv.load(".env.develop") // load `.env.development`
vdotenv.load(".env", ".env.develop") // load `.env` and `.env.develop`
You can write comments in the env file:
# This is comment
FOO=BAR
API_URL=YOUR_API_URL # This is inline comment
Installation and Import
Using vpm:
Install/Update:
v install zztkm.vdotenv
Import:
import zztkm.vdotenv
Using github (least recommended):
v install --git https://github.com/hungrybluedev/whisker
Import:
import vdotenv
Contributing
Contributing Guide for this repository.
License
TDOO
- cli app
- README: add tutorial(for dotenv beginner)