all: Use some Go 1.21 features (#9409)

This commit is contained in:
Jakob Borg
2024-02-10 21:02:42 +01:00
committed by GitHub
parent 96c30f8387
commit e1dd36561d
13 changed files with 23 additions and 72 deletions
+1 -20
View File
@@ -22,14 +22,12 @@ import (
"math"
"net"
"net/url"
"slices"
"sort"
"strings"
stdsync "sync"
"time"
"golang.org/x/exp/constraints"
"golang.org/x/exp/slices"
"github.com/syncthing/syncthing/lib/build"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/connections/registry"
@@ -1468,20 +1466,3 @@ func newConnectionID(t0, t1 int64) string {
// from the random. We want the timestamp part deterministic.
return enc.EncodeToString(buf[:8]) + enc.EncodeToString(buf[8:])
}
// temporary implementations of min and max, to be removed once we can use
// Go 1.21 builtins. :)
func min[T constraints.Ordered](a, b T) T {
if a < b {
return a
}
return b
}
func max[T constraints.Ordered](a, b T) T {
if a > b {
return a
}
return b
}