Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robusgauli/goenv
Manage environment variables in one go.
https://github.com/robusgauli/goenv
configuration-files dotenv dotenv-parser go golang
Last synced: about 2 months ago
JSON representation
Manage environment variables in one go.
- Host: GitHub
- URL: https://github.com/robusgauli/goenv
- Owner: RobusGauli
- License: mit
- Created: 2018-11-09T16:24:45.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-11T13:24:07.000Z (about 6 years ago)
- Last Synced: 2024-06-21T09:12:24.525Z (6 months ago)
- Topics: configuration-files, dotenv, dotenv-parser, go, golang
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
GoEnv: Fast Env Decoder to Go-Struct for Go
================================================What is this?
-------------This package loads environment variables into go-struct with validation built-in.
It also tries to load key-value pair from .env file within the root project directory if available.
- Fast implementation without Regexp.
- more options for validation and defaults.
Installation
------------```sh
go get -u github.com/RobusGauli/goenv
```Usage
-----Setup
```go
package mainimport (
"fmt"
"log""github.com/RobusGauli/goenv"
)// Config struct
type Config struct {
GoPath string `env:"GOPATH"`
JavaHome string `env:"JAVA_HOME"`
Pwd string `env:"PWD"`
}```
Vanilla Usage
```go
// initiate config struct
var config Config
if err := goenv.ParseEnv(&config); err != nil {
log.Fatal(err)
}
fmt.Println(config)
// Done
```