An open API service indexing awesome lists of open source software.

https://github.com/owlinux1000/go-envload

a tiny library to load enviroment variables to Golang struct.
https://github.com/owlinux1000/go-envload

Last synced: 9 months ago
JSON representation

a tiny library to load enviroment variables to Golang struct.

Awesome Lists containing this project

README

          

# go-envload

`go-envload` is a tiny library to load enviroment variables to Golang struct.

- **Features**
- `required` attribute
- `default=hogehoge` attribute
- **Not supported**
- Nested struct
- automatic type cast

## How to use

```go
package main

import (
"fmt"

"github.com/owlinux1000/go-envload"
)

func main() {
var cfg struct {
User string `env:"USER"`
ApiToken string `env:"API_TOKEN,required"`
Timeout string `env:"TIMEOUT,default=60"`
}
if err := envload.Load(&cfg); err != nil {
panic(err)
}
fmt.Printf("%v\n", cfg)
}
```