Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump go to v1.21 #2084

Merged
merged 4 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: "setup go"
uses: "actions/setup-go@v3"
with:
go-version: "1.20"
go-version: "1.21"
- name: "install python3-pytest"
run: "sudo apt install -y python3-pytest"
- name: "make install"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## build ergo binary
FROM golang:1.20-alpine AS build-env
FROM golang:1.21-alpine AS build-env

RUN apk upgrade -U --force-refresh --no-cache && apk add --no-cache --purge --clean-protected -l -u make git

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ergochat/ergo

go 1.20
go 1.21

require (
code.cloudfoundry.org/bytefmt v0.0.0-20200131002437-cf55d5288a48
Expand Down
3 changes: 2 additions & 1 deletion irc/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package irc

import (
"fmt"
"maps"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -158,7 +159,7 @@ func (channel *Channel) ExportRegistration() (info RegisteredChannel) {
info.Bans = channel.lists[modes.BanMask].Masks()
info.Invites = channel.lists[modes.InviteMask].Masks()
info.Excepts = channel.lists[modes.ExceptMask].Masks()
info.AccountToUMode = utils.CopyMap(channel.accountToUMode)
info.AccountToUMode = maps.Clone(channel.accountToUMode)

info.Settings = channel.settings

Expand Down
3 changes: 2 additions & 1 deletion irc/chanserv.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package irc
import (
"fmt"
"regexp"
"slices"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -218,7 +219,7 @@ func csAmodeHandler(service *ircService, server *Server, client *Client, command
// check for anything valid as a channel mode change that is not valid
// as an AMODE change
for _, modeChange := range modeChanges {
if !utils.SliceContains(modes.ChannelUserModes, modeChange.Mode) {
if !slices.Contains(modes.ChannelUserModes, modeChange.Mode) {
invalid = true
}
}
Expand Down
3 changes: 2 additions & 1 deletion irc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package irc
import (
"crypto/x509"
"fmt"
"maps"
"net"
"runtime/debug"
"strconv"
Expand Down Expand Up @@ -1743,7 +1744,7 @@ func (client *Client) handleRegisterTimeout() {
func (client *Client) copyLastSeen() (result map[string]time.Time) {
client.stateMutex.RLock()
defer client.stateMutex.RUnlock()
return utils.CopyMap(client.lastSeen)
return maps.Clone(client.lastSeen)
}

// these are bit flags indicating what part of the client status is "dirty"
Expand Down
5 changes: 2 additions & 3 deletions irc/fakelag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
package irc

import (
"maps"
"time"

"github.com/ergochat/ergo/irc/utils"
)

// fakelag is a system for artificially delaying commands when a user issues
Expand Down Expand Up @@ -40,7 +39,7 @@ func (fl *Fakelag) Initialize(config FakelagConfig) {
fl.config = config
// XXX don't share mutable member CommandBudgets:
if config.CommandBudgets != nil {
fl.config.CommandBudgets = utils.CopyMap(config.CommandBudgets)
fl.config.CommandBudgets = maps.Clone(config.CommandBudgets)
}
fl.nowFunc = time.Now
fl.sleepFunc = time.Sleep
Expand Down
3 changes: 2 additions & 1 deletion irc/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package irc

import (
"fmt"
"maps"
"net"
"time"

Expand Down Expand Up @@ -515,7 +516,7 @@ func (client *Client) GetReadMarker(cfname string) (result string) {
func (client *Client) copyReadMarkers() (result map[string]time.Time) {
client.stateMutex.RLock()
defer client.stateMutex.RUnlock()
return utils.CopyMap(client.readMarkers)
return maps.Clone(client.readMarkers)
}

func (client *Client) SetReadMarker(cfname string, now time.Time) (result time.Time) {
Expand Down
5 changes: 3 additions & 2 deletions irc/history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package history

import (
"slices"
"sync"
"time"

Expand Down Expand Up @@ -155,7 +156,7 @@ func (list *Buffer) betweenHelper(start, end Selector, cutoff time.Time, pred Pr

defer func() {
if !ascending {
utils.ReverseSlice(results)
slices.Reverse(results)
}
}()

Expand Down Expand Up @@ -262,7 +263,7 @@ func (list *Buffer) listCorrespondents(start, end Selector, cutoff time.Time, li
}

if !ascending {
utils.ReverseSlice(results)
slices.Reverse(results)
}

return
Expand Down
9 changes: 4 additions & 5 deletions irc/history/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
package history

import (
"slices"
"sort"
"time"

"github.com/ergochat/ergo/irc/utils"
)

type TargetListing struct {
Expand Down Expand Up @@ -35,8 +34,8 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T
results = make([]TargetListing, 0, prealloc)

if !ascending {
utils.ReverseSlice(base)
utils.ReverseSlice(extra)
slices.Reverse(base)
slices.Reverse(extra)
}

for len(results) < limit {
Expand Down Expand Up @@ -66,7 +65,7 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T
}

if !ascending {
utils.ReverseSlice(results)
slices.Reverse(results)
}
return
}
Expand Down
5 changes: 3 additions & 2 deletions irc/mysql/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"io"
"runtime/debug"
"slices"
"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -917,7 +918,7 @@ func (mysql *MySQL) betweenTimestamps(ctx context.Context, target, correspondent

results, err = mysql.selectItems(ctx, queryBuf.String(), args...)
if err == nil && !ascending {
utils.ReverseSlice(results)
slices.Reverse(results)
}
return
}
Expand Down Expand Up @@ -965,7 +966,7 @@ func (mysql *MySQL) listCorrespondentsInternal(ctx context.Context, target strin
}

if !ascending {
utils.ReverseSlice(results)
slices.Reverse(results)
}

return
Expand Down
24 changes: 0 additions & 24 deletions irc/utils/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,3 @@ func SetLiteral[T comparable](elems ...T) HashSet[T] {
}
return result
}

func CopyMap[K comparable, V any](input map[K]V) (result map[K]V) {
result = make(map[K]V, len(input))
for key, value := range input {
result[key] = value
}
return
}

// reverse the order of a slice in place
func ReverseSlice[T any](results []T) {
for i, j := 0, len(results)-1; i < j; i, j = i+1, j-1 {
results[i], results[j] = results[j], results[i]
}
}

func SliceContains[T comparable](slice []T, elem T) (result bool) {
for _, t := range slice {
if elem == t {
return true
}
}
return false
}