Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zztkm/vdotenv
Which loads env vars from a .env file.
https://github.com/zztkm/vdotenv
dotenv v v-module vlang vlang-module
Last synced: 2 days ago
JSON representation
Which loads env vars from a .env file.
- Host: GitHub
- URL: https://github.com/zztkm/vdotenv
- Owner: zztkm
- License: mit
- Created: 2020-06-27T09:34:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-11T04:09:01.000Z (3 months ago)
- Last Synced: 2024-08-11T05:32:03.850Z (3 months ago)
- Topics: dotenv, v, v-module, vlang, vlang-module
- Language: V
- Homepage:
- Size: 285 KB
- Stars: 33
- Watchers: 3
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: docs/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-v - vdotenv - Support for .env files which loads environment variables. (Libraries / Utility)
README
# dotenv module for V
[![Latest version][version-badge]][version-url] [![CI](https://github.com/zztkm/vdotenv/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/zztkm/vdotenv/actions/workflows/ci.yml)English
/ [Japanese](./docs/README_ja.md)vdotenv is a module to read environment variables from `.env` files
- Which loads env vars from a .env file.
- Existing environment variables can be overridden in the program
- Inspired by https://github.com/joho/godotenv.[module document.](docs/vdotenv.md)
## 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
```v
import osimport 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:
```v
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:
```v
import zztkm.vdotenv
```### Using github (least recommended):
```bash
v install --git https://github.com/hungrybluedev/whisker
```Import:
```v
import vdotenv
```## Contributing
[Contributing Guide for this repository.](docs/CONTRIBUTING.md)
## License
[MIT License](LICENSE.txt)
[docs]: https://github.com/zztkm/vdotenv
[version-badge]: https://img.shields.io/github/v/release/zztkm/vdotenv?logo=github&logoColor=white
[version-url]: https://github.com/zztkm/vdotenv/releases/latest
[workflow-badge]: https://img.shields.io/github/workflow/status/zztkm/vdotenv/CI?label=test&logo=github&logoColor=white
[workflow-url]: https://github.com/zztkm/vdotenv/actions?query=workflow%3ACI## TDOO
- [ ] [cli app](https://github.com/zztkm/vdotenv/issues/13)
- [ ] README: add tutorial(for dotenv beginner)## Acknowledgement
- [ivixvi](https://github.com/ivixvi)
- [ksk001100](https://github.com/ksk001100)
- [nyx-litenite](https://github.com/nyx-litenite)## Author
- [zztkm](https://github.com/zztkm/vdotenv)