Skip to content

fix: omit leading newline when formatting StackTrace with %+v#250

Closed
Solaris-star wants to merge 1 commit into
pkg:masterfrom
Solaris-star:fix/230-stacktrace-format-leading-newline
Closed

fix: omit leading newline when formatting StackTrace with %+v#250
Solaris-star wants to merge 1 commit into
pkg:masterfrom
Solaris-star:fix/230-stacktrace-format-leading-newline

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

fmt.Sprintf("%+v", stackTrace) prefixed every frame with a newline, including the first one. That made a bare StackTrace print with a leading blank line (#230).

Fix

In StackTrace.Format for %+v, write a newline only between frames (not before the first). Error formatting is unchanged because stack.Format still prefixes each frame with \n after the message.

Test plan

  • go test -vet=off .
  • Updated TestStackTraceFormat expectation
  • New TestStackTraceFormatNoLeadingNewline

Fixes #230

@puellanivis

Copy link
Copy Markdown

This is intended behavior.

@Solaris-star

Copy link
Copy Markdown
Author

Closing this based on maintainer feedback that the leading newline is intended behavior. Thanks for taking a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StackTrace.Format with "%+v" includes a leading newline

2 participants