All notable changes to oneenv are documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[1.1.0] - 2026-07-19
Added
Example[T]— generates a ready-to-fill.env.examplefrom a struct: each key with its default, preceded by comments carrying thedesctag, the Go type, and whether it is required. Defaults ofsecretfields are never written.- CLI
-exampleflag —oneenv -examplewrites a.env.examplefrom the merged.envfiles: keys kept, values stripped, original comments above each key preserved, plus inferred-type and required comments.-osets the output path (-for stdout, default.env.example).
1.0.0 - 2026-07-18
Initial release: a zero-dependency .env parser and struct decoder in one
package.
Added
- Core API —
Parse,Load,Unmarshal,LoadContext,ParseContext, and godotenv-styleRead,LoadEnv,Overload. - Types — ints/uints/floats,
bool,time.Duration,time.Time(withlayout), slices, maps, pointers, nested structs, and anyencoding.TextUnmarshaler. - Options — functional options:
WithFiles,WithEnvFiles,WithEnvVar,WithPrefix,WithOverride,WithExpand,WithRequired,WithTagKey,WithLookuper,WithTypeParser,WithMutator,WithValidator,WithContext. - Tags —
env(withrequired,notEmpty,file,init,unset,secretoptions),default,separator/envSeparator,layout,envPrefix,desc, plus anenv-*alias for every configuration tag (env-default,env-separator,env-description,env-layout,env-prefix,env-required,env-notempty,env-file,env-init,env-unset,env-secret). When both spellings are present theenv-*form takes priority. - Environment-aware file cascade —
WithEnvFiles()layers.env,.env.local,.env.<env>and.env.<env>.localby the active environment (APP_ENV, thenGO_ENV; configurable withWithEnvVar).FilesForexposes the resolved list. - Secrets —
env:"X,file"reads a value from the file at the resolved path;env:"X,secret"withRedacted/RedactedMapmasks values in output, and theSecret[T]wrapper keeps sensitive values out of logs and JSON while exposing the real value viaValue(). - Slices of structs — a
[]Structfield is decoded from indexed keys (SERVER_0_HOST,SERVER_1_HOST, …). - Hot reload — the
oneenv/watchsubpackage re-decodes on file change via native OS notifications (inotify on Linux, kqueue on BSD/macOS, ReadDirectoryChangesW on Windows) with modification-time polling as a fallback — all standard library, zero dependencies. - Marshal & Usage —
Marshal/MarshalMaprender a struct back to.env;Usageprints a--helptable of the variables a struct consumes. - Errors — positioned
*ParseError(file:line) and every field failure collected at once viaerrors.Join; sentinelsErrNotAStruct,ErrRequired,ErrEmpty,ErrSecretFile,ErrUnsupportedType. - Hermetic testing — a
Lookuperinterface (MapLookuper,OSLookuper,PrefixLookuper) with no global state, parallel-safe by design. - Runnable examples for the full API surface, so pkg.go.dev renders interactive examples.