all: use Go 1.21 slices, maps instead of x/exp/{slices,maps}

Updates #8419

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2023-08-16 22:09:53 -07:00 committed by Brad Fitzpatrick
parent e8d140654a
commit e8551d6b40
47 changed files with 61 additions and 65 deletions

View File

@ -168,9 +168,6 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
golang.org/x/crypto/nacl/box from tailscale.com/types/key
golang.org/x/crypto/nacl/secretbox from golang.org/x/crypto/nacl/box
golang.org/x/crypto/salsa20/salsa from golang.org/x/crypto/nacl/box+
golang.org/x/exp/constraints from golang.org/x/exp/slices
golang.org/x/exp/maps from tailscale.com/types/views+
golang.org/x/exp/slices from tailscale.com/net/tsaddr+
L golang.org/x/net/bpf from github.com/mdlayher/netlink+
golang.org/x/net/dns/dnsmessage from net+
golang.org/x/net/http/httpguts from net/http
@ -193,6 +190,7 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
golang.org/x/time/rate from tailscale.com/cmd/derper+
bufio from compress/flate+
bytes from bufio+
cmp from slices
compress/flate from compress/gzip+
compress/gzip from internal/profile+
container/list from crypto/tls+
@ -242,6 +240,7 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
io/ioutil from github.com/mitchellh/go-ps+
log from expvar+
log/internal from log
maps from tailscale.com/types/views
math from compress/flate+
math/big from crypto/dsa+
math/bits from compress/flate+
@ -269,6 +268,7 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
runtime/metrics from github.com/prometheus/client_golang/prometheus+
runtime/pprof from net/http/pprof
runtime/trace from net/http/pprof
slices from tailscale.com/ipn+
sort from compress/flate+
strconv from compress/flate+
strings from bufio+

View File

@ -12,13 +12,13 @@ import (
"fmt"
"net/http"
"os"
"slices"
"strings"
"time"
"github.com/go-logr/zapr"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"golang.org/x/exp/slices"
"golang.org/x/oauth2/clientcredentials"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"

View File

@ -35,14 +35,13 @@ import (
"net/http"
"net/netip"
"os"
"slices"
"strconv"
"strings"
"time"
"github.com/dsnet/try"
jsonv2 "github.com/go-json-experiment/json"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"tailscale.com/types/logid"
"tailscale.com/types/netlogtype"
"tailscale.com/util/cmpx"
@ -315,8 +314,8 @@ func mustMakeNamesByAddr() map[netip.Addr]string {
namesByAddr := make(map[netip.Addr]string)
retry:
for i := 0; i < 10; i++ {
maps.Clear(seen)
maps.Clear(namesByAddr)
clear(seen)
clear(namesByAddr)
for _, d := range m.Devices {
name := fieldPrefix(d.Name, i)
if seen[name] {

View File

@ -14,12 +14,12 @@ import (
"log"
"os"
"runtime"
"slices"
"strings"
"sync"
"text/tabwriter"
"github.com/peterbourgon/ff/v3/ffcli"
"golang.org/x/exp/slices"
"tailscale.com/client/tailscale"
"tailscale.com/envknob"
"tailscale.com/paths"

View File

@ -11,10 +11,10 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"github.com/peterbourgon/ff/v3/ffcli"
"golang.org/x/exp/slices"
"k8s.io/client-go/util/homedir"
"sigs.k8s.io/yaml"
"tailscale.com/version"

View File

@ -8,14 +8,13 @@ import (
"errors"
"flag"
"fmt"
"os"
"slices"
"strings"
"text/tabwriter"
"github.com/peterbourgon/ff/v3/ffcli"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"tailscale.com/ipn/ipnstate"
"tailscale.com/tailcfg"
"tailscale.com/util/cmpx"

View File

@ -9,11 +9,11 @@ import (
"fmt"
"net"
"os"
"slices"
"strconv"
"strings"
"github.com/peterbourgon/ff/v3/ffcli"
"golang.org/x/exp/slices"
"tailscale.com/ipn"
"tailscale.com/ipn/ipnstate"
"tailscale.com/tailcfg"

View File

@ -18,12 +18,12 @@ import (
"path/filepath"
"reflect"
"runtime"
"slices"
"sort"
"strconv"
"strings"
"github.com/peterbourgon/ff/v3/ffcli"
"golang.org/x/exp/slices"
"tailscale.com/client/tailscale"
"tailscale.com/ipn"
"tailscale.com/ipn/ipnstate"

View File

@ -168,9 +168,8 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
golang.org/x/crypto/nacl/secretbox from golang.org/x/crypto/nacl/box
golang.org/x/crypto/pbkdf2 from software.sslmate.com/src/go-pkcs12
golang.org/x/crypto/salsa20/salsa from golang.org/x/crypto/nacl/box+
golang.org/x/exp/constraints from golang.org/x/exp/slices+
golang.org/x/exp/maps from tailscale.com/types/views+
golang.org/x/exp/slices from tailscale.com/net/tsaddr+
W golang.org/x/exp/constraints from github.com/dblohm7/wingoes/pe
golang.org/x/exp/maps from tailscale.com/cmd/tailscale/cli
golang.org/x/net/bpf from github.com/mdlayher/netlink+
golang.org/x/net/dns/dnsmessage from net+
golang.org/x/net/http/httpguts from net/http+
@ -199,6 +198,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
golang.org/x/time/rate from tailscale.com/cmd/tailscale/cli+
bufio from compress/flate+
bytes from bufio+
cmp from slices
compress/flate from compress/gzip+
compress/gzip from net/http
compress/zlib from image/png+
@ -256,6 +256,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
io/ioutil from golang.org/x/sys/cpu+
log from expvar+
log/internal from log
maps from tailscale.com/types/views
math from compress/flate+
math/big from crypto/dsa+
math/bits from compress/flate+
@ -282,6 +283,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
regexp from github.com/tailscale/goupnp/httpu+
regexp/syntax from regexp
runtime/debug from tailscale.com/util/singleflight+
slices from tailscale.com/cmd/tailscale/cli+
sort from compress/flate+
strconv from compress/flate+
strings from bufio+

View File

@ -379,9 +379,8 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
golang.org/x/crypto/poly1305 from github.com/tailscale/golang-x-crypto/ssh+
golang.org/x/crypto/salsa20/salsa from golang.org/x/crypto/nacl/box+
LD golang.org/x/crypto/ssh from tailscale.com/ssh/tailssh+
golang.org/x/exp/constraints from golang.org/x/exp/slices+
golang.org/x/exp/maps from tailscale.com/wgengine+
golang.org/x/exp/slices from tailscale.com/ipn/ipnlocal+
golang.org/x/exp/constraints from github.com/dblohm7/wingoes/pe+
golang.org/x/exp/maps from tailscale.com/wgengine/magicsock
golang.org/x/net/bpf from github.com/mdlayher/genetlink+
golang.org/x/net/dns/dnsmessage from net+
golang.org/x/net/http/httpguts from golang.org/x/net/http2+
@ -467,6 +466,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
log from expvar+
log/internal from log
LD log/syslog from tailscale.com/ssh/tailssh
maps from tailscale.com/types/views
math from compress/flate+
math/big from crypto/dsa+
math/bits from compress/flate+
@ -496,7 +496,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
runtime/debug from github.com/klauspost/compress/zstd+
runtime/pprof from net/http/pprof+
runtime/trace from net/http/pprof
slices from tailscale.com/wgengine/magicsock
slices from tailscale.com/wgengine/magicsock+
sort from compress/flate+
strconv from compress/flate+
strings from bufio+

View File

@ -12,11 +12,11 @@ import (
"path"
"path/filepath"
"runtime"
"slices"
"strconv"
"time"
esbuild "github.com/evanw/esbuild/pkg/api"
"golang.org/x/exp/slices"
)
const (

View File

@ -6,9 +6,9 @@
package logknob
import (
"slices"
"sync/atomic"
"golang.org/x/exp/slices"
"tailscale.com/envknob"
"tailscale.com/types/logger"
)

View File

@ -27,12 +27,12 @@ import (
"os"
"path/filepath"
"runtime"
"slices"
"strings"
"sync"
"time"
"github.com/tailscale/golang-x-crypto/acme"
"golang.org/x/exp/slices"
"tailscale.com/atomicfile"
"tailscale.com/envknob"
"tailscale.com/hostinfo"

View File

@ -18,7 +18,6 @@ import (
"time"
"github.com/google/go-cmp/cmp"
"golang.org/x/exp/maps"
"tailscale.com/ipn/store/mem"
)
@ -112,7 +111,7 @@ func TestShouldStartDomainRenewal(t *testing.T) {
reset := func() {
renewMu.Lock()
defer renewMu.Unlock()
maps.Clear(renewCertAt)
clear(renewCertAt)
}
mustMakePair := func(template *x509.Certificate) *TLSCertKeyPair {

View File

@ -20,6 +20,7 @@ import (
"os/user"
"path/filepath"
"runtime"
"slices"
"sort"
"strconv"
"strings"
@ -29,7 +30,6 @@ import (
"go4.org/mem"
"go4.org/netipx"
"golang.org/x/exp/slices"
"gvisor.dev/gvisor/pkg/tcpip"
"tailscale.com/client/tailscale/apitype"
"tailscale.com/control/controlclient"

View File

@ -22,6 +22,7 @@ import (
"path"
"path/filepath"
"runtime"
"slices"
"sort"
"strconv"
"strings"
@ -32,7 +33,6 @@ import (
"unicode/utf8"
"github.com/kortschak/wol"
"golang.org/x/exp/slices"
"golang.org/x/net/dns/dnsmessage"
"golang.org/x/net/http/httpguts"
"tailscale.com/client/tailscale/apitype"

View File

@ -10,10 +10,10 @@ import (
"math/rand"
"net/netip"
"runtime"
"slices"
"strings"
"time"
"golang.org/x/exp/slices"
"tailscale.com/envknob"
"tailscale.com/ipn"
"tailscale.com/types/logger"

View File

@ -17,12 +17,12 @@ import (
"net/url"
"os"
"path"
"slices"
"strconv"
"strings"
"sync"
"time"
"golang.org/x/exp/slices"
"tailscale.com/ipn"
"tailscale.com/logtail/backoff"
"tailscale.com/net/netutil"

View File

@ -20,12 +20,12 @@ import (
"os/exec"
"path/filepath"
"runtime"
"slices"
"strings"
"sync"
"github.com/tailscale/golang-x-crypto/ssh"
"go4.org/mem"
"golang.org/x/exp/slices"
"tailscale.com/tailcfg"
"tailscale.com/util/lineread"
"tailscale.com/util/mak"

View File

@ -20,12 +20,12 @@ import (
"net/netip"
"net/url"
"runtime"
"slices"
"strconv"
"strings"
"sync"
"time"
"golang.org/x/exp/slices"
"tailscale.com/client/tailscale/apitype"
"tailscale.com/envknob"
"tailscale.com/health"

View File

@ -9,10 +9,10 @@ import (
"net"
"net/netip"
"net/url"
"slices"
"strconv"
"strings"
"golang.org/x/exp/slices"
"tailscale.com/tailcfg"
)

View File

@ -9,9 +9,8 @@ import (
"expvar"
"fmt"
"io"
"slices"
"strings"
"golang.org/x/exp/slices"
)
// Set is a string-to-Var map variable that satisfies the expvar.Var

View File

@ -12,11 +12,11 @@ import (
"net"
"net/netip"
"runtime"
"slices"
"strings"
"sync/atomic"
"time"
"golang.org/x/exp/slices"
"tailscale.com/health"
"tailscale.com/net/dns/resolver"
"tailscale.com/net/netmon"

View File

@ -10,11 +10,11 @@ import (
"fmt"
"net"
"net/netip"
"slices"
"strings"
"time"
"github.com/miekg/dns"
"golang.org/x/exp/slices"
"tailscale.com/envknob"
"tailscale.com/net/netns"
"tailscale.com/types/logger"

View File

@ -15,8 +15,9 @@ import (
"testing"
"time"
"slices"
"github.com/miekg/dns"
"golang.org/x/exp/slices"
"tailscale.com/envknob"
"tailscale.com/tstest"
)

View File

@ -19,11 +19,11 @@ import (
"net/url"
"os"
"reflect"
"slices"
"sync/atomic"
"time"
"go4.org/netipx"
"golang.org/x/exp/slices"
"tailscale.com/atomicfile"
"tailscale.com/envknob"
"tailscale.com/net/dns/recursive"

View File

@ -8,10 +8,10 @@ import (
"encoding/binary"
"errors"
"net/netip"
"slices"
"sync"
"go4.org/netipx"
"golang.org/x/exp/slices"
"tailscale.com/net/netaddr"
)

View File

@ -12,6 +12,7 @@ import (
"net/netip"
"os"
"reflect"
"slices"
"strings"
"sync"
"sync/atomic"
@ -20,7 +21,6 @@ import (
"github.com/tailscale/wireguard-go/device"
"github.com/tailscale/wireguard-go/tun"
"go4.org/mem"
"golang.org/x/exp/slices"
"gvisor.dev/gvisor/pkg/tcpip/stack"
"tailscale.com/disco"
"tailscale.com/net/connstats"

View File

@ -10,10 +10,10 @@ import (
"errors"
"fmt"
"runtime"
"slices"
"sync"
"time"
"golang.org/x/exp/slices"
"tailscale.com/envknob"
)

View File

@ -22,6 +22,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"slices"
"sort"
"strconv"
"strings"
@ -31,7 +32,6 @@ import (
"github.com/pkg/sftp"
"github.com/u-root/u-root/pkg/termios"
gossh "golang.org/x/crypto/ssh"
"golang.org/x/exp/slices"
"golang.org/x/sys/unix"
"tailscale.com/cmd/tailscaled/childproc"
"tailscale.com/hostinfo"

View File

@ -15,11 +15,11 @@ import (
"reflect"
"regexp"
"runtime"
"slices"
"strconv"
"syscall"
"testing"
"golang.org/x/exp/slices"
"tailscale.com/types/logger"
)

View File

@ -9,7 +9,6 @@ import (
"sync"
"sync/atomic"
"golang.org/x/exp/maps"
"tailscale.com/util/mak"
)
@ -232,7 +231,7 @@ func (m *Map[K, V]) Len() int {
func (m *Map[K, V]) Clear() {
m.mu.Lock()
defer m.mu.Unlock()
maps.Clear(m.m)
clear(m.m)
}
// WaitGroup is identical to [sync.WaitGroup],

View File

@ -4,6 +4,7 @@ package ssh
import (
"bytes"
"io"
"net"
"strconv"
"strings"

View File

@ -22,12 +22,12 @@ import (
"os"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"
"sync"
"time"
"golang.org/x/exp/slices"
"tailscale.com/client/tailscale"
"tailscale.com/control/controlclient"
"tailscale.com/envknob"

View File

@ -4,11 +4,11 @@
package tstest
import (
"slices"
"sync/atomic"
"testing"
"time"
"golang.org/x/exp/slices"
"tailscale.com/tstime"
)

View File

@ -19,6 +19,7 @@ import (
"net/http/httptest"
"net/netip"
"net/url"
"slices"
"sort"
"strings"
"sync"
@ -26,7 +27,6 @@ import (
"github.com/klauspost/compress/zstd"
"go4.org/mem"
"golang.org/x/exp/slices"
"tailscale.com/net/netaddr"
"tailscale.com/net/tsaddr"
"tailscale.com/smallzstd"

View File

@ -11,9 +11,8 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
"slices"
"unicode/utf8"
"golang.org/x/exp/slices"
)
// PrivateID represents a log steam for writing.

View File

@ -8,10 +8,10 @@ package views
import (
"encoding/json"
"errors"
"maps"
"net/netip"
"slices"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"tailscale.com/net/tsaddr"
)

View File

@ -7,9 +7,8 @@ package multierr
import (
"errors"
"slices"
"strings"
"golang.org/x/exp/slices"
)
// An Error represents multiple errors.

View File

@ -4,7 +4,8 @@
package set
import (
"golang.org/x/exp/slices"
"slices"
"tailscale.com/types/views"
)

View File

@ -5,9 +5,8 @@ package slicesx
import (
"reflect"
"slices"
"testing"
"golang.org/x/exp/slices"
)
func TestInterleave(t *testing.T) {

View File

@ -7,11 +7,11 @@ package filter
import (
"fmt"
"net/netip"
"slices"
"sync"
"time"
"go4.org/netipx"
"golang.org/x/exp/slices"
"tailscale.com/envknob"
"tailscale.com/net/flowtrack"
"tailscale.com/net/netaddr"

View File

@ -7,6 +7,7 @@ import (
"encoding/hex"
"fmt"
"net/netip"
"slices"
"strconv"
"strings"
"testing"
@ -14,7 +15,6 @@ import (
"github.com/google/go-cmp/cmp"
"go4.org/netipx"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"tailscale.com/net/packet"
"tailscale.com/net/tsaddr"
"tailscale.com/tailcfg"

View File

@ -11,13 +11,13 @@ import (
"log"
"net"
"net/netip"
"slices"
"sort"
"time"
ole "github.com/go-ole/go-ole"
"github.com/tailscale/wireguard-go/tun"
"go4.org/netipx"
"golang.org/x/exp/slices"
"golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
"tailscale.com/health"

View File

@ -11,6 +11,7 @@ import (
"os"
"reflect"
"regexp"
"slices"
"sort"
"strings"
"sync"
@ -21,7 +22,6 @@ import (
"github.com/tailscale/wireguard-go/tun"
"github.com/vishvananda/netlink"
"go4.org/netipx"
"golang.org/x/exp/slices"
"tailscale.com/net/netmon"
"tailscale.com/net/tsaddr"
"tailscale.com/tstest"

View File

@ -19,7 +19,6 @@ import (
"github.com/tailscale/wireguard-go/device"
"github.com/tailscale/wireguard-go/tun"
"golang.org/x/exp/maps"
"tailscale.com/control/controlclient"
"tailscale.com/envknob"
"tailscale.com/health"
@ -619,7 +618,7 @@ func (e *userspaceEngine) maybeReconfigWireguardLocked(discoChanged map[key.Node
// Don't re-alloc the map; the Go compiler optimizes map clears as of
// Go 1.11, so we can re-use the existing + allocated map.
if e.trimmedNodes != nil {
maps.Clear(e.trimmedNodes)
clear(e.trimmedNodes)
} else {
e.trimmedNodes = make(map[key.NodePublic]bool)
}

View File

@ -8,9 +8,9 @@ import (
"bytes"
"fmt"
"net/netip"
"slices"
"strings"
"golang.org/x/exp/slices"
"tailscale.com/net/tsaddr"
"tailscale.com/tailcfg"
"tailscale.com/types/logger"