all: use any instead of interface{}

My favorite part of generics.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder
2022-03-16 16:27:57 -07:00
committed by Josh Bleecher Snyder
parent 5f176f24db
commit 0868329936
88 changed files with 204 additions and 204 deletions

View File

@@ -258,7 +258,7 @@ func TestLinuxDNSMode(t *testing.T) {
}
}
type memFS map[string]interface{} // full path => string for regular files
type memFS map[string]any // full path => string for regular files
func (m memFS) Stat(name string) (isRegular bool, err error) {
v, ok := m[name]

View File

@@ -140,12 +140,12 @@ func (m *nmManager) trySet(ctx context.Context, config OSConfig) error {
// NetworkManager wipes out IPv6 address configuration unless we
// tell it explicitly to keep it. Read out the current interface
// settings and mirror them out to NetworkManager.
var addrs6 []map[string]interface{}
var addrs6 []map[string]any
addrs, _, err := interfaces.Tailscale()
if err == nil {
for _, a := range addrs {
if a.Is6() {
addrs6 = append(addrs6, map[string]interface{}{
addrs6 = append(addrs6, map[string]any{
"address": a.String(),
"prefix": uint32(128),
})

View File

@@ -141,7 +141,7 @@ func (m *resolvedManager) resync(ctx context.Context, signals chan *dbus.Signal)
if signal.Path != dbusPath || signal.Name != dbusInterface+"."+dbusOwnerSignal {
continue
}
// signal.Body is a []interface{} of 3 strings: bus name, previous owner, new owner.
// signal.Body is a []any of 3 strings: bus name, previous owner, new owner.
if len(signal.Body) != 3 {
m.logf("[unexpectected] DBus NameOwnerChanged len(Body) = %d, want 3")
}

View File

@@ -711,7 +711,7 @@ type response struct {
}
var dnsParserPool = &sync.Pool{
New: func() interface{} {
New: func() any {
return new(dnsParser)
},
}

View File

@@ -221,7 +221,7 @@ func weirdoGoCNAMEHandler(target string) dns.HandlerFunc {
// provided.
//
// Types supported: netaddr.IP.
func dnsHandler(answers ...interface{}) dns.HandlerFunc {
func dnsHandler(answers ...any) dns.HandlerFunc {
return func(w dns.ResponseWriter, req *dns.Msg) {
m := new(dns.Msg)
m.SetReply(req)
@@ -303,7 +303,7 @@ func dnsHandler(answers ...interface{}) dns.HandlerFunc {
}
}
func serveDNS(tb testing.TB, addr string, records ...interface{}) *dns.Server {
func serveDNS(tb testing.TB, addr string, records ...any) *dns.Server {
if len(records)%2 != 0 {
panic("must have an even number of record values")
}

View File

@@ -454,7 +454,7 @@ func TestDelegate(t *testing.T) {
// intend to handle responses this large, so there should be truncation.
hugeTXT := generateTXT(64000, randSource)
records := []interface{}{
records := []any{
"test.site.",
resolveToIP(testipv4, testipv6, "dns.test.site."),
"LCtesT.SiTe.",
@@ -1105,7 +1105,7 @@ func TestHandleExitNodeDNSQueryWithNetPkg(t *testing.T) {
t.Skip("skipping test on Windows; waiting for golang.org/issue/33097")
}
records := []interface{}{
records := []any{
"no-records.test.",
dnsHandler(),