Skip to content

Commit

Permalink
panic: make it work on go1.7.6
Browse files Browse the repository at this point in the history
Replace sort.Slice() with strings.FieldsFunc().

sort.Slice() was introduced in go1.8.

I need panic to work on go1.7 to diagnose an issue with
'additional frames elided' not being printed anymore.
  • Loading branch information
maruel committed Jun 2, 2019
1 parent 0953091 commit 5c1041f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/panic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os"
"runtime"
"sort"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -224,18 +225,17 @@ var types = map[string]struct {
"stdlib": {
"panics with stdlib in the call stack, with both exported and unexpected functions",
func() {
a := []string{"a", "b"}
sort.Slice(a, func(i, j int) bool {
strings.FieldsFunc("a", func(rune) bool {
panic("allo")
return false
})
},
},

"stdlib_and_other": {
"panics with both other and stdlib packages in the call stack",
func() {
a := []string{"a", "b"}
sort.Slice(a, func(i, j int) bool {
strings.FieldsFunc("a", func(rune) bool {
internal.Callback(func() {
panic("allo")
})
Expand Down

0 comments on commit 5c1041f

Please sign in to comment.