5 // IncorrectSort tries to sort an integer.
8 sortFn := func(i, j int) bool { return false }
9 sort.Slice(i, sortFn) // want "sort.Slice's argument must be a slice; is called with int"
12 // CorrectSort sorts integers. It should not produce a diagnostic.
14 s := []int{2, 3, 5, 6}
15 sortFn := func(i, j int) bool { return s[i] < s[j] }
19 // CorrectInterface sorts an interface with a slice
20 // as the concrete type. It should not produce a diagnostic.
21 func CorrectInterface() {
23 s = interface{}([]int{2, 1, 0})
24 sortFn := func(i, j int) bool { return s.([]int)[i] < s.([]int)[j] }
28 type slicecompare interface {
29 compare(i, j int) bool
34 func (s intslice) compare(i, j int) bool {
38 // UnderlyingInterface sorts an interface with a slice
39 // as the concrete type. It should not produce a diagnostic.
40 func UnderlyingInterface() {
42 s = intslice([]int{2, 1, 0})
43 sort.Slice(s, s.compare)
48 // UnderlyingSlice sorts a type with an underlying type of
49 // slice of ints. It should not produce a diagnostic.
50 func UnderlyingSlice() {
51 s := mySlice{2, 3, 5, 6}
52 sortFn := func(i, j int) bool { return s[i] < s[j] }