All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Improved test coverage for error cases in
setValue
- Removed
assertfunctionality (was not part of core API)
EnvCollectorinterface for handling dynamic environment variables that can't be expressed via struct tags (e.g.,USER_1,PASS_1,USER_2,PASS_2)EnvGetterinterface withLookup,ReadValue, andReadmethods for use within collectors- Pointer validation in
EnvGetter.ReadValue
- Custom unmarshalers (
TextUnmarshaler, etc.) now requireenvtag, notenvPrefix
- Whole-struct decoding via
envPrefix(was buggy, returned nil-wrapped errors)
- README: OS env takes precedence over
.envfile, not vice versa
Validatorinterface for custom field validation after population- Code coverage badge workflow
- Simplified internal decoding logic
- Core API: Generic
Read[T]function to populate structs from environment variables - Struct Tags:
env:"NAME"- specify environment variable nameenvDefault:"VALUE"- fallback when variable is unsetenvRequired:"true"- error if variable is unset and no defaultenvPrefix:"PREFIX"- prefix for nested struct fieldsenv:"-"- skip field entirely
- Nested Structs: Support for embedded/anonymous structs with optional prefix
- Type Support:
- Primitives: string, bool, all int/uint sizes, float32/64
time.Duration(parsed viatime.ParseDuration)- Slices: comma-separated values (e.g.,
"a,b,c") - Arrays: comma-separated values with length validation
- Maps: comma-separated key=value pairs (e.g.,
"k1=v1,k2=v2") - Pointers to any supported type (auto-allocated)
- Custom Decoding: Support for types implementing
encoding.TextUnmarshaler,encoding.BinaryUnmarshaler,json.Unmarshaler - Dotenv Support:
LoadDotEnv()helper to load.envfiles - Custom Lookup: Pass custom lookup function to
Readfor alternative env sources - IgnoreEmptyEnvLookup: Helper that treats empty values as unset
- Strict validation for missing/invalid tags
- Treat empty env values as nil slice/map (not empty allocation)
- Avoid unnecessary map allocation for empty values