From ae2f828b1427b87e9e5d68c0069fe44fb4f46123 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sun, 14 Apr 2024 17:59:59 +0200 Subject: [PATCH] Use Go 1.21 as the lowest supported version --- go.mod | 2 +- go.sum | 2 ++ internal/transport/bridge/recv.go | 9 +++------ internal/transport/bridge/send.go | 9 +++------ 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index d54f6cc3..9f9c16d7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Jacalz/rymdport/v3 -go 1.19 +go 1.21 require ( fyne.io/fyne/v2 v2.4.4 diff --git a/go.sum b/go.sum index 3a9f2d12..0c764193 100644 --- a/go.sum +++ b/go.sum @@ -100,6 +100,7 @@ github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8/go.mod h1:h29xCucjN github.com/go-text/typesetting v0.1.0 h1:vioSaLPYcHwPEPLT7gsjCGDCoYSbljxoHJzMnKwVvHw= github.com/go-text/typesetting v0.1.0/go.mod h1:d22AnmeKq/on0HNv73UFriMKc4Ez6EqZAofLhAzpSzI= github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04 h1:zBx+p/W2aQYtNuyZNcTfinWvXBQwYtDfme051PR/lAY= +github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -171,6 +172,7 @@ github.com/gopherjs/gopherjs v0.0.0-20211219123610-ec9572f70e60/go.mod h1:cz9oNY github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g= github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/goxjs/gl v0.0.0-20210104184919-e3fafc6f8f2a/go.mod h1:dy/f2gjY09hwVfIyATps4G2ai7/hLwLkc5TrPqONuXY= github.com/goxjs/glfw v0.0.0-20191126052801-d2efb5f20838/go.mod h1:oS8P8gVOT4ywTcjV6wZlOU4GuVFQ8F5328KY3MJ79CY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= diff --git a/internal/transport/bridge/recv.go b/internal/transport/bridge/recv.go index 469b8bb2..e465426a 100644 --- a/internal/transport/bridge/recv.go +++ b/internal/transport/bridge/recv.go @@ -2,6 +2,7 @@ package bridge import ( "path/filepath" + "slices" "sync/atomic" "time" @@ -191,12 +192,8 @@ func (d *RecvData) remove(index int) { // Make sure that no updates happen while we modify the slice. d.deleting.Store(true) - if index < len(d.items)-1 { - copy(d.items[index:], d.items[index+1:]) - } - - d.items[len(d.items)-1] = nil // Allow the GC to reclaim memory. - d.items = d.items[:len(d.items)-1] + d.items[index] = nil // TODO: Remove once we have Go 1.22 as the base. + d.items = slices.Delete(d.items, index, index+1) // Update the moved items to have the correct index. for j := index; j < len(d.items); j++ { diff --git a/internal/transport/bridge/send.go b/internal/transport/bridge/send.go index 0d21c921..bd15532b 100644 --- a/internal/transport/bridge/send.go +++ b/internal/transport/bridge/send.go @@ -2,6 +2,7 @@ package bridge import ( "path/filepath" + "slices" "sync/atomic" "fyne.io/fyne/v2" @@ -340,12 +341,8 @@ func (d *SendData) remove(index int) { // Make sure that no updates happen while we modify the slice. d.deleting.Store(true) - if index < len(d.items)-1 { - copy(d.items[index:], d.items[index+1:]) - } - - d.items[len(d.items)-1] = nil // Allow the GC to reclaim memory. - d.items = d.items[:len(d.items)-1] + d.items[index] = nil // TODO: Remove once we have Go 1.22 as the base. + d.items = slices.Delete(d.items, index, index+1) // Update the moved items to have the correct index. for j := index; j < len(d.items); j++ {