Skip to content

v0.3.0

Choose a tag to compare

@ableinc ableinc released this 24 May 23:37
· 2 commits to main since this release

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