ksk001100 / vdotenv

Which loads env vars from a .env file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dotenv module for V

English / Japanese

Which loads env vars from a .env file.
Inspired by https://github.com/joho/godotenv.

module document.

Installation and Import

Using vpm:

Install/Update:

v install zztkm.vdotenv

Import:

import zztkm.vdotenv

Using github (least recommended):

Install (from your project folder):

git clone https://github.com/zztkm/vdotenv.git

Update (from your project folder):

cd vdotenv
git pull

Import:

import vdotenv

Usage

Add your application configuration to your .env file in the root of your project:

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

Contributing

Contributing Guide for this repository.

License

MIT License

About

Which loads env vars from a .env file.

License:MIT License


Languages

Language:V 94.2%Language:AMPL 5.8%