diff --git a/packet-manager.go b/packet-manager.go index 8c6691cf..bf822e67 100644 --- a/packet-manager.go +++ b/packet-manager.go @@ -2,6 +2,7 @@ package sftp import ( "encoding" + "sort" "sync" ) @@ -37,6 +38,22 @@ func newPktMgr(sender packetSender) *packetManager { return s } +type responsePackets []responsePacket + +func (r responsePackets) Sort() { + sort.Slice(r, func(i, j int) bool { + return r[i].id() < r[j].id() + }) +} + +type requestPacketIDs []uint32 + +func (r requestPacketIDs) Sort() { + sort.Slice(r, func(i, j int) bool { + return r[i] < r[j] + }) +} + // register incoming packets to be handled // send id of 0 for packets without id func (s *packetManager) incomingPacket(pkt requestPacket) { diff --git a/packet-manager_go1.8.go b/packet-manager_go1.8.go deleted file mode 100644 index ccae8c1d..00000000 --- a/packet-manager_go1.8.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build go1.8 - -package sftp - -import "sort" - -type responsePackets []responsePacket - -func (r responsePackets) Sort() { - sort.Slice(r, func(i, j int) bool { - return r[i].id() < r[j].id() - }) -} - -type requestPacketIDs []uint32 - -func (r requestPacketIDs) Sort() { - sort.Slice(r, func(i, j int) bool { - return r[i] < r[j] - }) -} diff --git a/packet-manager_legacy.go b/packet-manager_legacy.go deleted file mode 100644 index 97f0ff09..00000000 --- a/packet-manager_legacy.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build !go1.8 - -package sftp - -import "sort" - -// for sorting/ordering outgoing -type responsePackets []responsePacket - -func (r responsePackets) Len() int { return len(r) } -func (r responsePackets) Swap(i, j int) { r[i], r[j] = r[j], r[i] } -func (r responsePackets) Less(i, j int) bool { return r[i].id() < r[j].id() } -func (r responsePackets) Sort() { sort.Sort(r) } - -// for sorting/ordering incoming -type requestPacketIDs []uint32 - -func (r requestPacketIDs) Len() int { return len(r) } -func (r requestPacketIDs) Swap(i, j int) { r[i], r[j] = r[j], r[i] } -func (r requestPacketIDs) Less(i, j int) bool { return r[i] < r[j] } -func (r requestPacketIDs) Sort() { sort.Sort(r) }