Two solutions come to mind. You can pick what works for you.
- Panicparse
Marc-Antoine Ruel -- fantastic developer -- created panicparse. Run your program, assign stderr to stdout, pipe that into panicparse, and you're good to go.
go run example.go 2>&1 | pp
Panicparse will deduplicate and dedensify the output >50% while also making it far more readable.
Check out the screenshots in the README.
- Head
If the information you're looking for is always at the top of the stacktrace, then maybe it's just a simple case of piping the output to head.
We want to run our program; allowing it to output to stdout/terminal like normal, but we want to limit the amount of information the panic displays with head. Remember, panics are written to stderr. So piping stderr to a process substitution should work on most systems:
go run example.go 2> >(head)