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: 10 months 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 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-21T10:10:54.000Z (about 5 years ago)
- Last Synced: 2025-02-09T12:19:23.347Z (about 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 [](https://goreportcard.com/report/github.com/lalabuy948/genvutils) [](https://github.com/lalabuy948/genvutils/actions) [](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`