Skip to content

Instantly share code, notes, and snippets.

@lggomezml
lggomezml / stacktrace.go
Created July 17, 2019 13:53
Get a compact stacktrace without the callsites
var newLine = []byte("\n")[0]
var goPathPrefix = "\t/go/src/"
var goUsersPrefix = "\t/Users/"
func dumpStacktrace(skipLines int) []byte {
stack := debug.Stack()
init, lines := 0, 0
// First pass: seek stack start skiping lines if necessary
if skipLines > 0 {