Repository navigation
refactor!: capture stacks with the runtime package - #22
Merged
Merged
Conversation
Remove the exported Wrapper field, deprecated in v0.7.0, and the github.com/go-errors/errors dependency. Constructors capture program counters with runtime.Callers (at most 50 frames) and StackTrace and StackTraceStr resolve them with runtime.CallersFrames on every call, caching nothing on the shared error, so concurrent reads stay race-free. Frames keep their package, name, file and line format. A function inlined into its caller now shows its real name and line. BREAKING CHANGE: Error.Wrapper is removed; use Detail, StackTrace or StackTraceStr. github.com/jgolang/log must be v1.7.3 or later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
ERR-07 phase 3 (owner-approved 2026-11-21): remove the exported
Error.Wrapperfield (deprecated in v0.7.0) and thegithub.com/go-errors/errorsdependency; stacks use theruntimepackage. Leaves out any other API change. Not a stack. Planned on top: ajgolang/logPR raising errors to v0.8.0 (log v1.7.4).Reason
Wrapper *goerrors.Errortied this leaf module's public API to its only third-party dependency, which it used only to capture and format stacks;runtime.Callers/runtime.CallersFramesdo that (KISS-01). log stopped readingWrapperin v1.7.3. Decision recorded indocs/adr/0002-standard-library-stack-traces.md.Changes
errors.go,functions.go: unexportedwrapped errorandstack *callStackreplaceWrapper. Constructors capture up to 50 program counters withruntime.Callers(same skip, same cap as go-errors).StackTrace/StackTraceStrresolve frames withruntime.CallersFrameson every call and cache nothing on the shared value, so concurrent reads are race-free by construction (ERR-06). Package/name split matches go-errors, so the format is unchanged. The stack sits behind a pointer soErrorstays comparable with==.go.mod: go-errors removed;go.sumis empty and deleted.Wrapper; added exact top-frame tests (both formats), 50-frame cap, nil receiver, inlined caller, compile-time comparability check. Addederrors_benchmark_test.go.README.md, ADR 0002.Output differences
errors.Newfor such frames.*goerrors.Errornow captures a fresh stack instead of reusing its stack.Verification
gofmt -l .empty,go vet ./...,go test -race ./...,govulncheck ./...clean;go list -m alllists only this module;go doc -all .diff shows only the removed field.runtime.CallersFramesiterator). Time: an interleaved run shows no significant change (noise on this machine is ±15–30%).Release notes (v0.8.0)
Breaking:
Error.Wrapperis removed. UseDetailfor the wrapped cause's text andStackTrace/StackTraceStrfor the stack.github.com/jgolang/log, require log v1.7.3 or later. Older log releases readWrapperand fail to compile against v0.8.0.Changed:
github.com/go-errors/errorsis gone (its globalMaxStackDepthno longer affects this module; the depth is fixed at 50).*goerrors.Errorcaptures a new stack at the call site.🤖 Generated with Claude Code