Skip to content

Releases: ableinc/go-env

v0.3.2

Choose a tag to compare

@ableinc ableinc released this 02 Sep 12:00

Full Changelog: v0.3.1...v0.3.2

v0.3.1

Choose a tag to compare

@ableinc ableinc released this 24 May 23:49

v0.3.1

Bug Fixes

  • Inline comments are now stripped from .env values — values like DATABASE_URL=postgres://... # or sqlite3:///data/app.db previously 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.Setenv acquires an internal global lock on every call, so concurrent goroutines were serializing anyway while adding goroutine creation and sync.WaitGroup overhead. LoadEnv now uses a simple sequential loop, which is measurably faster. This also removes the sync and runtime import dependencies.

Internal

  • Removed MAX_ENV_THRESHOLD constant and setEnvFromPairs helper (both made dead by the above change)
  • Fixed a variable shadowing issue in parseEnvFile where the closing-quote search index end shadowed the outer newline-offset end

v0.3.0

Choose a tag to compare

@ableinc ableinc released this 24 May 23:37

v0.3.0

Bug Fixes

  • Process now accepts *Struct directly — 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.Duration field support — struct fields of type time.Duration are now parsed using time.ParseDuration, so values like "15m", "30s", and "168h" work in both env vars and default tags.
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 Process reflection logic to unwrap *Struct → Struct (and still handle *interface{} → interface{} → Struct for backward compatibility)
  • Added time.Duration type check in setField before the reflect.Kind switch
  • Expanded test suite with 11 new Process tests covering defaults, env overrides, required fields, time.Duration parsing, split_words, ignored fields, untagged fields, and invalid inputs

v0.2.0

Choose a tag to compare

@ableinc ableinc released this 24 May 23:16

v0.2.0

New Features

  • Process function — map .env variables directly into a struct using struct tags (envconfig, split_words, required, default, ignored). Supports string, int, uint, float, and bool field types.
  • Optional filepath on LoadEnv and Process — both functions now accept an optional filepath argument. When omitted, .env is loaded by default, removing the need to pass nil or a pointer.

Breaking Changes

  • LoadEnv signature changed: LoadEnv(filepath *string, verbose bool) → LoadEnv(filepath ...string)
  • Process signature changed: Process(s any, filepath *string) → Process(s any, filepath ...string)
  • The verbose parameter has been removed from LoadEnv

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 Makefile with test and build targets
  • Added CI via GitHub Actions
  • go fix applied across codebase
  • Updated README with full API reference and struct tag documentation

Migration: Replace goenv.LoadEnv(&file, false) with goenv.LoadEnv(file), and goenv.Process(&cfg, nil) with goenv.Process(&cfg).

v0.1.6

Choose a tag to compare

@ableinc ableinc released this 24 May 00:51

Changelog

  1. Optimized env parsing and deduplication (last key wins) with safer worker scaling and lower memory use.
  2. Reworked tests to use fixture .env.test files for <50 and >50 cases plus invalid/duplicate scenarios.
  3. Added Makefile targets (fmt, build, test, tidy) and CI workflow running build + tests.

v0.1.5

Choose a tag to compare

@ableinc ableinc released this 18 May 00:31
  • Fixed bug related to commented and empty lines
  • Fixed bug with .env files larger than 20 lines

v0.1.4

Choose a tag to compare

@ableinc ableinc released this 14 Apr 01:46

bug fixes

v0.1.0

Choose a tag to compare

@ableinc ableinc released this 07 Apr 14:50

Initial release