Browse Source

Merge pull request #2084 from slingamn/go_upgrade_121

bump go to v1.21
tags/v2.12.0-rc1
Shivaram Lingamneni 9 months ago
parent
commit
3b3e8c0004
No account linked to committer's email address
12 changed files with 23 additions and 43 deletions
  1. 1
    1
      .github/workflows/build.yml
  2. 1
    1
      Dockerfile
  3. 1
    1
      go.mod
  4. 2
    1
      irc/channel.go
  5. 2
    1
      irc/chanserv.go
  6. 2
    1
      irc/client.go
  7. 2
    3
      irc/fakelag.go
  8. 2
    1
      irc/getters.go
  9. 3
    2
      irc/history/history.go
  10. 4
    5
      irc/history/targets.go
  11. 3
    2
      irc/mysql/history.go
  12. 0
    24
      irc/utils/types.go

+ 1
- 1
.github/workflows/build.yml View File

@@ -19,7 +19,7 @@ jobs:
19 19
       - name: "setup go"
20 20
         uses: "actions/setup-go@v3"
21 21
         with:
22
-          go-version: "1.20"
22
+          go-version: "1.21"
23 23
       - name: "install python3-pytest"
24 24
         run: "sudo apt install -y python3-pytest"
25 25
       - name: "make install"

+ 1
- 1
Dockerfile View File

@@ -1,5 +1,5 @@
1 1
 ## build ergo binary
2
-FROM golang:1.20-alpine AS build-env
2
+FROM golang:1.21-alpine AS build-env
3 3
 
4 4
 RUN apk upgrade -U --force-refresh --no-cache && apk add --no-cache --purge --clean-protected -l -u make git
5 5
 

+ 1
- 1
go.mod View File

@@ -1,6 +1,6 @@
1 1
 module github.com/ergochat/ergo
2 2
 
3
-go 1.20
3
+go 1.21
4 4
 
5 5
 require (
6 6
 	code.cloudfoundry.org/bytefmt v0.0.0-20200131002437-cf55d5288a48

+ 2
- 1
irc/channel.go View File

@@ -7,6 +7,7 @@ package irc
7 7
 
8 8
 import (
9 9
 	"fmt"
10
+	"maps"
10 11
 	"strconv"
11 12
 	"strings"
12 13
 	"time"
@@ -158,7 +159,7 @@ func (channel *Channel) ExportRegistration() (info RegisteredChannel) {
158 159
 	info.Bans = channel.lists[modes.BanMask].Masks()
159 160
 	info.Invites = channel.lists[modes.InviteMask].Masks()
160 161
 	info.Excepts = channel.lists[modes.ExceptMask].Masks()
161
-	info.AccountToUMode = utils.CopyMap(channel.accountToUMode)
162
+	info.AccountToUMode = maps.Clone(channel.accountToUMode)
162 163
 
163 164
 	info.Settings = channel.settings
164 165
 

+ 2
- 1
irc/chanserv.go View File

@@ -6,6 +6,7 @@ package irc
6 6
 import (
7 7
 	"fmt"
8 8
 	"regexp"
9
+	"slices"
9 10
 	"sort"
10 11
 	"strings"
11 12
 	"time"
@@ -218,7 +219,7 @@ func csAmodeHandler(service *ircService, server *Server, client *Client, command
218 219
 	// check for anything valid as a channel mode change that is not valid
219 220
 	// as an AMODE change
220 221
 	for _, modeChange := range modeChanges {
221
-		if !utils.SliceContains(modes.ChannelUserModes, modeChange.Mode) {
222
+		if !slices.Contains(modes.ChannelUserModes, modeChange.Mode) {
222 223
 			invalid = true
223 224
 		}
224 225
 	}

+ 2
- 1
irc/client.go View File

@@ -8,6 +8,7 @@ package irc
8 8
 import (
9 9
 	"crypto/x509"
10 10
 	"fmt"
11
+	"maps"
11 12
 	"net"
12 13
 	"runtime/debug"
13 14
 	"strconv"
@@ -1743,7 +1744,7 @@ func (client *Client) handleRegisterTimeout() {
1743 1744
 func (client *Client) copyLastSeen() (result map[string]time.Time) {
1744 1745
 	client.stateMutex.RLock()
1745 1746
 	defer client.stateMutex.RUnlock()
1746
-	return utils.CopyMap(client.lastSeen)
1747
+	return maps.Clone(client.lastSeen)
1747 1748
 }
1748 1749
 
1749 1750
 // these are bit flags indicating what part of the client status is "dirty"

+ 2
- 3
irc/fakelag.go View File

@@ -4,9 +4,8 @@
4 4
 package irc
5 5
 
6 6
 import (
7
+	"maps"
7 8
 	"time"
8
-
9
-	"github.com/ergochat/ergo/irc/utils"
10 9
 )
11 10
 
12 11
 // fakelag is a system for artificially delaying commands when a user issues
@@ -40,7 +39,7 @@ func (fl *Fakelag) Initialize(config FakelagConfig) {
40 39
 	fl.config = config
41 40
 	// XXX don't share mutable member CommandBudgets:
42 41
 	if config.CommandBudgets != nil {
43
-		fl.config.CommandBudgets = utils.CopyMap(config.CommandBudgets)
42
+		fl.config.CommandBudgets = maps.Clone(config.CommandBudgets)
44 43
 	}
45 44
 	fl.nowFunc = time.Now
46 45
 	fl.sleepFunc = time.Sleep

+ 2
- 1
irc/getters.go View File

@@ -5,6 +5,7 @@ package irc
5 5
 
6 6
 import (
7 7
 	"fmt"
8
+	"maps"
8 9
 	"net"
9 10
 	"time"
10 11
 
@@ -515,7 +516,7 @@ func (client *Client) GetReadMarker(cfname string) (result string) {
515 516
 func (client *Client) copyReadMarkers() (result map[string]time.Time) {
516 517
 	client.stateMutex.RLock()
517 518
 	defer client.stateMutex.RUnlock()
518
-	return utils.CopyMap(client.readMarkers)
519
+	return maps.Clone(client.readMarkers)
519 520
 }
520 521
 
521 522
 func (client *Client) SetReadMarker(cfname string, now time.Time) (result time.Time) {

+ 3
- 2
irc/history/history.go View File

@@ -4,6 +4,7 @@
4 4
 package history
5 5
 
6 6
 import (
7
+	"slices"
7 8
 	"sync"
8 9
 	"time"
9 10
 
@@ -155,7 +156,7 @@ func (list *Buffer) betweenHelper(start, end Selector, cutoff time.Time, pred Pr
155 156
 
156 157
 	defer func() {
157 158
 		if !ascending {
158
-			utils.ReverseSlice(results)
159
+			slices.Reverse(results)
159 160
 		}
160 161
 	}()
161 162
 
@@ -262,7 +263,7 @@ func (list *Buffer) listCorrespondents(start, end Selector, cutoff time.Time, li
262 263
 	}
263 264
 
264 265
 	if !ascending {
265
-		utils.ReverseSlice(results)
266
+		slices.Reverse(results)
266 267
 	}
267 268
 
268 269
 	return

+ 4
- 5
irc/history/targets.go View File

@@ -4,10 +4,9 @@
4 4
 package history
5 5
 
6 6
 import (
7
+	"slices"
7 8
 	"sort"
8 9
 	"time"
9
-
10
-	"github.com/ergochat/ergo/irc/utils"
11 10
 )
12 11
 
13 12
 type TargetListing struct {
@@ -35,8 +34,8 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T
35 34
 	results = make([]TargetListing, 0, prealloc)
36 35
 
37 36
 	if !ascending {
38
-		utils.ReverseSlice(base)
39
-		utils.ReverseSlice(extra)
37
+		slices.Reverse(base)
38
+		slices.Reverse(extra)
40 39
 	}
41 40
 
42 41
 	for len(results) < limit {
@@ -66,7 +65,7 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T
66 65
 	}
67 66
 
68 67
 	if !ascending {
69
-		utils.ReverseSlice(results)
68
+		slices.Reverse(results)
70 69
 	}
71 70
 	return
72 71
 }

+ 3
- 2
irc/mysql/history.go View File

@@ -11,6 +11,7 @@ import (
11 11
 	"fmt"
12 12
 	"io"
13 13
 	"runtime/debug"
14
+	"slices"
14 15
 	"strings"
15 16
 	"sync"
16 17
 	"sync/atomic"
@@ -917,7 +918,7 @@ func (mysql *MySQL) betweenTimestamps(ctx context.Context, target, correspondent
917 918
 
918 919
 	results, err = mysql.selectItems(ctx, queryBuf.String(), args...)
919 920
 	if err == nil && !ascending {
920
-		utils.ReverseSlice(results)
921
+		slices.Reverse(results)
921 922
 	}
922 923
 	return
923 924
 }
@@ -965,7 +966,7 @@ func (mysql *MySQL) listCorrespondentsInternal(ctx context.Context, target strin
965 966
 	}
966 967
 
967 968
 	if !ascending {
968
-		utils.ReverseSlice(results)
969
+		slices.Reverse(results)
969 970
 	}
970 971
 
971 972
 	return

+ 0
- 24
irc/utils/types.go View File

@@ -27,27 +27,3 @@ func SetLiteral[T comparable](elems ...T) HashSet[T] {
27 27
 	}
28 28
 	return result
29 29
 }
30
-
31
-func CopyMap[K comparable, V any](input map[K]V) (result map[K]V) {
32
-	result = make(map[K]V, len(input))
33
-	for key, value := range input {
34
-		result[key] = value
35
-	}
36
-	return
37
-}
38
-
39
-// reverse the order of a slice in place
40
-func ReverseSlice[T any](results []T) {
41
-	for i, j := 0, len(results)-1; i < j; i, j = i+1, j-1 {
42
-		results[i], results[j] = results[j], results[i]
43
-	}
44
-}
45
-
46
-func SliceContains[T comparable](slice []T, elem T) (result bool) {
47
-	for _, t := range slice {
48
-		if elem == t {
49
-			return true
50
-		}
51
-	}
52
-	return false
53
-}

Loading…
Cancel
Save