Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%+v is too verbose #5

Open
tebeka opened this issue Feb 23, 2020 · 0 comments
Open

%+v is too verbose #5

tebeka opened this issue Feb 23, 2020 · 0 comments

Comments

@tebeka
Copy link

tebeka commented Feb 23, 2020

When printing error which have causes with %+v verb, you'll get the stack trace several times.

main.go

package main

import (
	"fmt"

	"github.com/friendsofgo/errors"
)

func a() error {
	return errors.Errorf("a")
}

func b() error {
	err := a()
	return errors.Wrap(err, "b")
}

func c() error {
	err := b()
	return errors.Wrap(err, "c")
}

func main() {
	err := c()
	fmt.Printf("%+v\n", err)
}

Running

$ go run main.go
a
main.a
	/tmp/pe/main.go:10
main.b
	/tmp/pe/main.go:14
main.c
	/tmp/pe/main.go:19
main.main
	/tmp/pe/main.go:24
runtime.main
	/opt/go/src/runtime/proc.go:203
runtime.goexit
	/opt/go/src/runtime/asm_amd64.s:1357
b
main.b
	/tmp/pe/main.go:15
main.c
	/tmp/pe/main.go:19
main.main
	/tmp/pe/main.go:24
runtime.main
	/opt/go/src/runtime/proc.go:203
runtime.goexit
	/opt/go/src/runtime/asm_amd64.s:1357
c
main.c
	/tmp/pe/main.go:20
main.main
	/tmp/pe/main.go:24
runtime.main
	/opt/go/src/runtime/proc.go:203
runtime.goexit
	/opt/go/src/runtime/asm_amd64.s:1357
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

No branches or pull requests

1 participant