Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lalabuy948/genvutils
Go environment utilities (genvutils) - provides useful environment variables operations
https://github.com/lalabuy948/genvutils
dotenv dotenv-loader dotenv-parser golang golang-library golang-tools
Last synced: 6 days ago
JSON representation
Go environment utilities (genvutils) - provides useful environment variables operations
- Host: GitHub
- URL: https://github.com/lalabuy948/genvutils
- Owner: lalabuy948
- License: mit
- Created: 2020-08-16T21:18:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-21T10:10:54.000Z (about 4 years ago)
- Last Synced: 2023-07-28T12:57:20.122Z (over 1 year ago)
- Topics: dotenv, dotenv-loader, dotenv-parser, golang, golang-library, golang-tools
- Language: Go
- Homepage: https://pkg.go.dev/github.com/lalabuy948/genvutils
- Size: 30.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# genvutils [![Go Report Card](https://goreportcard.com/badge/github.com/lalabuy948/genvutils)](https://goreportcard.com/report/github.com/lalabuy948/genvutils) [![Build Status](https://github.com/lalabuy948/genvutils/workflows/build/badge.svg)](https://github.com/lalabuy948/genvutils/actions) [![made-with-Go](https://img.shields.io/badge/Made%20with-Go-1f425f.svg)](http://golang.org)
> Package genvutils provides useful environment operations
## Funcs
- `IsProduction`, `IsDevelopment` and `IsTesting` checks for `ENVIRONMENT` dot env value.
- `GetEnv` gets env value or fallback which goes as second function argument.
- `Parse` will fill given struct with env values or with fallbacks. (see examples folder)
```go
type serverConfig struct {
ServerPort string `genv:"SERVER_PORT,8080"`
MongoUrl string `genv:"MONGO_URL,mongodb://localhost:27017"`
}
```
- `Load` will load dotenv file. You can provide file name via argument otherwise it will load dot environment file by priority list.
First found - first load. Priority list:
```sh
.env.production.local
.env.test.local
.env.development.local
.env.production
.env.test
.env.development
.env.local !!! will override existing values.
.env
```[example](examples/simple.go)
## Install
`go get -u github.com/lalabuy948/genvutils`