Repository navigation
Releases: ableinc/go-env
Releases · ableinc/go-env
Release list
v0.3.2
v0.3.1
v0.3.1
Bug Fixes
- Inline comments are now stripped from
.envvalues — values likeDATABASE_URL=postgres://... # or sqlite3:///data/app.dbpreviously included the comment text verbatim, causing connection errors. Anything after#or\t#in an unquoted value is now discarded.
New Features
- Single-quoted values —
'value'is now handled alongside"value". Quoted values are taken verbatim with no comment stripping, allowing#to appear inside them freely.
Performance
- Removed goroutine-based parallel env loading —
os.Setenvacquires an internal global lock on every call, so concurrent goroutines were serializing anyway while adding goroutine creation andsync.WaitGroupoverhead.LoadEnvnow uses a simple sequential loop, which is measurably faster. This also removes thesyncandruntimeimport dependencies.
Internal
- Removed
MAX_ENV_THRESHOLDconstant andsetEnvFromPairshelper (both made dead by the above change) - Fixed a variable shadowing issue in
parseEnvFilewhere the closing-quote search indexendshadowed the outer newline-offsetend
v0.3.0
v0.3.0
Bug Fixes
Processnow accepts*Structdirectly — the function previously required an indirect*interface{}wrapping, causing a runtime error (Process: expected interface, got struct) when called the standard way (goenv.Process(&cfg)). It now correctly accepts a plain pointer to a struct.
New Features
time.Durationfield support — struct fields of typetime.Durationare now parsed usingtime.ParseDuration, so values like"15m","30s", and"168h"work in both env vars anddefaulttags.
type Config struct {
JWTAccessTTL time.Duration `envconfig:"JWT_ACCESS_TTL" default:"15m"`
JWTRefreshTTL time.Duration `envconfig:"JWT_REFRESH_TTL" default:"168h"`
}What's Changed
- Fixed
Processreflection logic to unwrap*Struct→Struct(and still handle*interface{}→interface{}→Structfor backward compatibility) - Added
time.Durationtype check insetFieldbefore thereflect.Kindswitch - Expanded test suite with 11 new
Processtests covering defaults, env overrides, required fields,time.Durationparsing,split_words,ignoredfields, untagged fields, and invalid inputs
v0.2.0
v0.2.0
New Features
Processfunction — map.envvariables directly into a struct using struct tags (envconfig,split_words,required,default,ignored). Supportsstring,int,uint,float, andboolfield types.- Optional filepath on
LoadEnvandProcess— both functions now accept an optional filepath argument. When omitted,.envis loaded by default, removing the need to passnilor a pointer.
Breaking Changes
LoadEnvsignature changed:LoadEnv(filepath *string, verbose bool)→LoadEnv(filepath ...string)Processsignature changed:Process(s any, filepath *string)→Process(s any, filepath ...string)- The
verboseparameter has been removed fromLoadEnv
Performance Improvements
- Parallel env loading for files with 50+ variables — chunks are distributed across workers sized to available CPUs
- Memory improvements to env file parsing (pre-allocated slices, zero-copy byte scanning)
Bug Fixes
- Duplicate key handling: last occurrence now consistently wins
- Fixed concurrency issues related to env file size thresholds
Other
- Added
Makefilewithtestandbuildtargets - Added CI via GitHub Actions
go fixapplied across codebase- Updated README with full API reference and struct tag documentation
Migration: Replace
goenv.LoadEnv(&file, false)withgoenv.LoadEnv(file), andgoenv.Process(&cfg, nil)withgoenv.Process(&cfg).
v0.1.6
Changelog
- Optimized env parsing and deduplication (last key wins) with safer worker scaling and lower memory use.
- Reworked tests to use fixture
.env.testfiles for <50 and >50 cases plus invalid/duplicate scenarios. - Added Makefile targets (
fmt,build,test,tidy) and CI workflow running build + tests.