Public API: - Unmarshal(dst, opts...) - UnmarshalPrefix(dst, prefix, opts...) - AsMap() / AsMapPrefix(prefix) - Options: WithTrim, WithWeaklyTyped, WithTagName, WithDecodeHook Merges three divergent in-repo copies (ai-fabric/pkg/env, markets-platform/TP-general-code/pkg/system, and the var/agents/issue-* snapshots), adds error wrapping, prefix filter, and pluggable hooks. 15 pure-Go unit tests, no synthetic mocks, lint clean. Extracted per inventar/docs/asr/ASR-0008-ai-fabric-audit.md.
1.2 KiB
1.2 KiB
Changelog
All notable changes to go-env are documented here.
The format is based on Keep a Changelog
and this project adheres to Semantic Versioning.
[Unreleased]
[0.1.0] - 2026-04-24
Initial release. Extracted from produktor.io/ai-fabric/pkg/env per
inventar/docs/asr/ASR-0008-ai-fabric-audit.md.
Added
Unmarshal(dst, opts...)— decode all process env vars into a Go struct.UnmarshalPrefix(dst, prefix, opts...)— prefix-scoped variant that strips the prefix before building the path.AsMap()/AsMapPrefix(prefix)— escape hatch returning the nestedmap[string]anybuilt fromos.Environ().- Options:
WithTrim,WithWeaklyTyped,WithTagName,WithDecodeHook. - TrimSpace on string values is enabled by default; disable with
WithTrim(false). - Error wrapping with
%won both decoder configuration and decode failures — matchesmarkets-platform/TP-general-code/pkg/systembehaviour, improves on the original ai-fabric version.
Tests
- 15 pure-Go unit tests. No mocks.
asMapFromEnvironis tested with syntheticenvironslices (not a mock — a pure input). Follows the eSlidergo-*no-synthetic-mocks policy.