v1.139.0
v1.139.0
Broad hardening, performance, and API-ergonomics pass across the utility packages. Every touched package keeps 100% test coverage and a clean strict golangci-lint run, with new fuzz targets and benchmarks throughout.
✨ Features
- redact: Rework the redaction engine into a generic, allocation-free single-pass scanner for logs, HTTP dumps, JSON, XML, and form data. Adds detection for extra sensitive HTTP headers, URL userinfo passwords, JWT/JWE tokens, vendor credential literals (GitHub, GitLab, Slack, Stripe, AWS, Google, OpenAI/Anthropic, and more), and PEM private-key blocks; broadens credit-card detection to 13–19 digit PANs with grouped formats and a conservative Maestro policy; and guarantees convergent redaction backed by a permanent fuzz target. Introduces the canonical
String/Bytes/AppendTo/BytesToString/PooledAPI and a configurableRedactor(WithMarker,WithLuhnCheck,WithExtraTokens,WithoutTokens,WithoutRules), withHTTPData*retained as compatibility aliases. - dnscache: Add host normalization (case-fold + trailing-dot trim), IP-literal bypass, canonical de-duplication of resolved addresses, and RFC 6724-aware IPv4/IPv6 interleaving. Adds family-restricted network filtering,
errors.Joinfailure aggregation, sentinel errorsErrNoAddresses/ErrInvalidIP, and functional optionsWithDialer,WithDialTimeout,WithAddressRotation, andWithStaleIfError. - mysqllock: Add configurable keep-alive tuning (
WithKeepAliveInterval,WithKeepAlivePingTimeout,WithReleaseTimeout), explicit lock-loss signaling viaErrLockLostand per-acquisition/instanceWithLostLockHandler, and a robust idempotent release path. Fixes a deadlock when releasing from within a lock-loss handler, bounds keep-alive pings to detect hung connections, and adds sentinel errorsErrNilDB,ErrInvalidKey, andErrInvalidTimeout. - timeutil: Add sentinel errors
ErrInvalidDuration,ErrDurationOverflow, andErrParseDateTime; implementencoding.TextMarshaler/TextUnmarshaleronDurationandDateTime(usable as JSON map keys and with YAML/TOML/flag.TextVar); fix numeric overflow inDuration.UnmarshalJSON; and treat JSONnullas a no-op. - paging: Add
HasPreviousPage/HasNextPageflags (has_previous_page/has_next_page) so callers can toggle navigation links without re-deriving boundary conditions.
🐛 Fixes
- validator: Drop the custom
einoverride in favor of the upstream built-in, fill in missing error templates (bcp47_strict_language_tag,mimetype,noneof,noneofci,origin), parsefalseifnumeric params in base 10, and validate error templates at registration time. GuardsisE164NoPlus/isUSZIPCodeagainst non-string fields. - strsplit: Fix
ChunkLineemitting a blank chunk for whitespace-only input shorter than the size. RefactorsChunk/ChunkLineinto single-purpose helpers (output byte-for-byte identical), pre-sizes result slices, and clarifies byte-size semantics and boundary handling. - testutil: Bound
ReplaceDateTimeto the RFC3339 grammar andReplaceUnixTimestampto a word-bounded 19-digit match; fixCaptureOutputto restore the logger's real destination and close both pipe ends on every exit path (avoiding a goroutine/FD leak); tightenNewErrorCloser's exported surface to exactlyio.ReadCloser.
⚡ Performance
- random: Reduce allocations and speed up UUID/UID generation. UUIDv7 reads entropy into a stack buffer (~3% faster),
RandStringmaps accepted bytes in place (4→2 allocs, ~12% faster at n=16), andTUID128/TUID64gain zero-allocationFormat/Bytemethods (TUID128.Hex~36% faster,String3→1 allocs, ~28% faster). - uhex: Use a 256-entry lookup table for ~2–3× faster fixed-width hex encoding.
- stringkey: Single-pass field normalization (collapse whitespace + lowercase together) with
norm.NFC.Byteson a pre-grown buffer;BenchmarkNewdrops from 9→2 allocs/op and ~30% faster with byte-identical output. ReimplementsHexviapkg/uhex. - stringmetric: Flatten the DP matrix to a single row-major slice, cutting allocations 15→4 and improving cache locality, plus documented metric guarantees.
🔧 Chores
- make: Cap benchmarks in the
testtarget with-benchtime=1x(compile/race smoke check) and add a dedicatedbenchtarget for real measurements; mirrored into theexamples/servicescaffold. - deps: Update dependencies.
Full Changelog: v1.138.0...v1.139.0