Repository navigation
Fix leading newline in StackTrace %+v output - #255
Open
draarivpatel-ui wants to merge 1 commit into
Open
draarivpatel-ui wants to merge 1 commit into
draarivpatel-ui wants to merge 1 commit into
Conversation
Formatting a StackTrace directly with %+v prefixed every frame with a newline, including the first, so the output always began with a stray blank line. Frames are now separated by newlines instead of each being prefixed with one. The verbose error formatting in fundamental and withStack writes the separator newline before the first frame, so the output of %+v on errors themselves is unchanged; only direct formatting of a StackTrace loses the spurious leading newline. Fixes pkg#230
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.
Summary
Formatting a
StackTracedirectly with%+vprefixed every frame with a newline, including the first one, so the output always began with a stray blank line:Frames are now separated by newlines instead of each being prefixed with one. The verbose error formatting in
fundamentalandwithStackwrites the separator newline before the first frame, so the output of%+von errors themselves is byte-for-byte unchanged (the "between each frame" option discussed in the issue); only direct formatting of aStackTraceloses the spurious leading newline. Empty and nil stacks still print nothing.Test plan
TestStackTraceFormatNoLeadingNewlineas a regression test: it failed before the fix and passes after.TestStackTraceFormatexpectation, which encoded the buggy leading newline (flagged in the issue as needing care).TestFormatNew,TestFormatWrap,TestFormatWithStack, ...) pass unchanged, confirming verbose error output is identical.errors_test.goand theTestStackTraceline-number drift from inlining. Both fail identically before and after this change.Fixes #230