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.
- Host: GitHub
- URL: https://github.com/owlinux1000/go-envload
- Owner: owlinux1000
- Created: 2023-07-24T12:46:18.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-24T20:45:22.000Z (almost 3 years ago)
- Last Synced: 2025-03-06T00:25:43.659Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: docs/README.md
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)
}
```