Skip to content

Commit b40b921

Browse files
authored
fix: use slices.Sort method instead of sort.Slice (#1014)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 99845f4 commit b40b921

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

protocol/handshake/server.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package handshake
1717
import (
1818
"errors"
1919
"fmt"
20-
"sort"
20+
"slices"
2121

2222
"github.com/blinklabs-io/gouroboros/protocol"
2323
)
@@ -105,9 +105,7 @@ func (s *Server) handleProposeVersions(msg protocol.Message) error {
105105
}
106106

107107
// sort asending - iterating over map is not deterministic
108-
sort.Slice(supportedVersions, func(i, j int) bool {
109-
return supportedVersions[i] < supportedVersions[j]
110-
})
108+
slices.Sort(supportedVersions)
111109

112110
msgRefuse := NewMsgRefuse(
113111
[]any{

protocol/versions.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
package protocol
1616

17-
import "sort"
17+
import "slices"
1818

1919
// The NtC protocol versions have the 15th bit set in the handshake
2020
const ProtocolVersionNtCOffset = 0x8000
@@ -322,9 +322,7 @@ func GetProtocolVersionsNtC() []uint16 {
322322
}
323323

324324
// sort asending - iterating over map is not deterministic
325-
sort.Slice(versions, func(i, j int) bool {
326-
return versions[i] < versions[j]
327-
})
325+
slices.Sort(versions)
328326

329327
return versions
330328
}
@@ -339,9 +337,7 @@ func GetProtocolVersionsNtN() []uint16 {
339337
}
340338

341339
// sort asending - iterating over map is not deterministic
342-
sort.Slice(versions, func(i, j int) bool {
343-
return versions[i] < versions[j]
344-
})
340+
slices.Sort(versions)
345341

346342
return versions
347343
}

0 commit comments

Comments
 (0)