Skip to content

Commit

Permalink
fix: Go 1.21 fully qualified function names
Browse files Browse the repository at this point in the history
  • Loading branch information
greywolve committed Sep 8, 2023
1 parent 7232f7e commit b026f44
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions stacktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,21 @@ func createFrames(frames []runtime.Frame) []Frame {
}
}

// Walk backwards through the results and for the current function name
// remove it's parent function's prefix, leaving only it's actual name. This
// fixes issues grouping errors with the new fully qualified function names
// introduced from Go 1.21.
for i := len(result) - 1; i > 0; i-- {
name := result[i].Function
parentName := result[i-1].Function + "."

if !strings.HasPrefix(name, parentName) {
continue
}

result[i].Function = name[len(parentName):]
}

return result
}

Expand Down

0 comments on commit b026f44

Please sign in to comment.