https://github.com/metafates/ev
⛳ Typed environment variables for Go
https://github.com/metafates/ev
Last synced: 8 months ago
JSON representation
⛳ Typed environment variables for Go
- Host: GitHub
- URL: https://github.com/metafates/ev
- Owner: metafates
- License: mit
- Created: 2025-08-01T18:14:20.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-01T18:19:37.000Z (11 months ago)
- Last Synced: 2025-08-01T20:37:12.863Z (11 months ago)
- Language: Go
- Homepage: https://pkg.go.dev/github.com/metafates/ev
- Size: 7.81 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ev
> E(nvironment) v(ariable)
Tiny Go library to create typed environment variables.
```bash
go get github.com/metafates/ev
```
## Example
```go
const MyEnvVar ev.Var[int] = "MY_ENV_VAR"
const Verbose ev.Var[bool] = "VERBOSE"
func main() {
// assume we have the following variables set
os.Setenv("MY_ENV_VAR", "42")
os.Setenv("VERBOSE", "true")
if Verbose.Get() {
n := MyEnvVar.Get()
fmt.Println(n + n) // prints 84
}
}
```
Supported types:
``` go
type Constraint interface {
int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr | float32 | float64
}
```
Values are parsed using `fmt.Sscanf`.