Releases: bakhod1r/oneenv
Releases · bakhod1r/oneenv
Release list
oneenv v1.0.0
oneenv — parse .env files straight into your Go structs. Zero dependencies, pure stdlib.
type Config struct {
Port int `env:"PORT" default:"8080"`
Host string `env:"HOST,required"`
APIKey oneenv.Secret[string] `env:"API_KEY"`
DB DBConfig `envPrefix:"DB_"`
}
cfg, err := oneenv.Parse[Config](oneenv.WithEnvFiles())Highlights
- Straight to struct — a dotenv parser and an env-to-struct decoder behind one fast, cached API.
- Environment-aware file cascade —
WithEnvFiles()layers.env,.env.local,.env.<env>and.env.<env>.localbyAPP_ENV/GO_ENV, like Rails and Next.js. - Secrets —
,filereads a value from a path (Docker/K8s);,secret+Redactedand theSecret[T]wrapper keep sensitive values out of logs and JSON. - Slices of structs — repeated config from indexed keys (
SERVER_0_HOST,SERVER_1_HOST, …). - Hot reload — the
oneenv/watchsubpackage re-decodes on file change via native OS notifications: inotify (Linux), kqueue (BSD/macOS), ReadDirectoryChangesW (Windows), with polling as a fallback — still zero external dependencies. - Rich types — ints/floats/bool,
time.Duration,time.Time, slices, maps, pointers, nested structs, and anyencoding.TextUnmarshaler. - Extensible — custom per-type parsers, value mutators and a pluggable validator, all dependency-free.
- Round-trips & help —
Marshalrenders a struct back to.env;Usageprints a--helptable. - Great errors — positioned parse errors (
file:line) and every field failure collected at once viaerrors.Join. - Hermetic tests — a
Lookuperinterface means no global state, parallel-safe by design.
Install
go get github.com/bakhod1r/oneenv@v1.0.0Requires Go 1.26+.