Skip to content

v1.139.0

Choose a tag to compare

@github-actions github-actions released this 07 Jul 22:54
f0e6429

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/Pooled API and a configurable Redactor (WithMarker, WithLuhnCheck, WithExtraTokens, WithoutTokens, WithoutRules), with HTTPData* 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.Join failure aggregation, sentinel errors ErrNoAddresses/ErrInvalidIP, and functional options WithDialer, WithDialTimeout, WithAddressRotation, and WithStaleIfError.
  • mysqllock: Add configurable keep-alive tuning (WithKeepAliveInterval, WithKeepAlivePingTimeout, WithReleaseTimeout), explicit lock-loss signaling via ErrLockLost and per-acquisition/instance WithLostLockHandler, 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 errors ErrNilDB, ErrInvalidKey, and ErrInvalidTimeout.
  • timeutil: Add sentinel errors ErrInvalidDuration, ErrDurationOverflow, and ErrParseDateTime; implement encoding.TextMarshaler/TextUnmarshaler on Duration and DateTime (usable as JSON map keys and with YAML/TOML/flag.TextVar); fix numeric overflow in Duration.UnmarshalJSON; and treat JSON null as a no-op.
  • paging: Add HasPreviousPage/HasNextPage flags (has_previous_page/has_next_page) so callers can toggle navigation links without re-deriving boundary conditions.

🐛 Fixes

  • validator: Drop the custom ein override in favor of the upstream built-in, fill in missing error templates (bcp47_strict_language_tag, mimetype, noneof, noneofci, origin), parse falseif numeric params in base 10, and validate error templates at registration time. Guards isE164NoPlus/isUSZIPCode against non-string fields.
  • strsplit: Fix ChunkLine emitting a blank chunk for whitespace-only input shorter than the size. Refactors Chunk/ChunkLine into single-purpose helpers (output byte-for-byte identical), pre-sizes result slices, and clarifies byte-size semantics and boundary handling.
  • testutil: Bound ReplaceDateTime to the RFC3339 grammar and ReplaceUnixTimestamp to a word-bounded 19-digit match; fix CaptureOutput to restore the logger's real destination and close both pipe ends on every exit path (avoiding a goroutine/FD leak); tighten NewErrorCloser's exported surface to exactly io.ReadCloser.

⚡ Performance

  • random: Reduce allocations and speed up UUID/UID generation. UUIDv7 reads entropy into a stack buffer (~3% faster), RandString maps accepted bytes in place (4→2 allocs, ~12% faster at n=16), and TUID128/TUID64 gain zero-allocation Format/Byte methods (TUID128.Hex ~36% faster, String 3→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.Bytes on a pre-grown buffer; BenchmarkNew drops from 9→2 allocs/op and ~30% faster with byte-identical output. Reimplements Hex via pkg/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 test target with -benchtime=1x (compile/race smoke check) and add a dedicated bench target for real measurements; mirrored into the examples/service scaffold.
  • deps: Update dependencies.

Full Changelog: v1.138.0...v1.139.0