From 5c1041f880794dca189c646026c13ce90c1e5799 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Ruel Date: Sat, 1 Jun 2019 21:06:44 -0400 Subject: [PATCH] panic: make it work on go1.7.6 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. --- cmd/panic/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/panic/main.go b/cmd/panic/main.go index 5d93118..d7c5a51 100644 --- a/cmd/panic/main.go +++ b/cmd/panic/main.go @@ -26,6 +26,7 @@ import ( "os" "runtime" "sort" + "strings" "sync" "time" @@ -224,9 +225,9 @@ 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 }) }, }, @@ -234,8 +235,7 @@ var types = map[string]struct { "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") })