Skip to content

Releases: bakhod1r/oneenv

Release list

oneenv v1.0.0

Choose a tag to compare

@bakhod1r bakhod1r released this 18 Jul 14:57

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 cascadeWithEnvFiles() layers .env, .env.local, .env.<env> and .env.<env>.local by APP_ENV/GO_ENV, like Rails and Next.js.
  • Secrets,file reads a value from a path (Docker/K8s); ,secret + Redacted and the Secret[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/watch subpackage 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 any encoding.TextUnmarshaler.
  • Extensible — custom per-type parsers, value mutators and a pluggable validator, all dependency-free.
  • Round-trips & helpMarshal renders a struct back to .env; Usage prints a --help table.
  • Great errors — positioned parse errors (file:line) and every field failure collected at once via errors.Join.
  • Hermetic tests — a Lookuper interface means no global state, parallel-safe by design.

Install

go get github.com/bakhod1r/oneenv@v1.0.0

Requires Go 1.26+.

See the CHANGELOG and README for full details.