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

@@ -37,7 +37,7 @@ type strCache struct {
// and rewrites peer keys from wireguard-go into Tailscale format.
func NewLogger(logf logger.Logf) *Logger {
ret := new(Logger)
wrapper := func(format string, args ...interface{}) {
wrapper := func(format string, args ...any) {
if strings.Contains(format, "Routine:") && !strings.Contains(format, "receive incoming") {
// wireguard-go logs as it starts and stops routines.
// Drop those; there are a lot of them, and they're just noise.
@@ -60,7 +60,7 @@ func NewLogger(logf logger.Logf) *Logger {
}
// Duplicate the args slice so that we can modify it.
// This is not always required, but the code required to avoid it is not worth the complexity.
newargs := make([]interface{}, len(args))
newargs := make([]any, len(args))
copy(newargs, args)
for i, arg := range newargs {
// We want to replace *device.Peer args with the Tailscale-formatted version of themselves.

View File

@@ -18,22 +18,22 @@ import (
func TestLogger(t *testing.T) {
tests := []struct {
format string
args []interface{}
args []any
want string
omit bool
}{
{"hi", nil, "hi", false},
{"Routine: starting", nil, "", true},
{"%v says it misses you", []interface{}{stringer("peer(IMTB…r7lM)")}, "[IMTBr] says it misses you", false},
{"%v says it misses you", []any{stringer("peer(IMTB…r7lM)")}, "[IMTBr] says it misses you", false},
}
type log struct {
format string
args []interface{}
args []any
}
c := make(chan log, 1)
logf := func(format string, args ...interface{}) {
logf := func(format string, args ...any) {
select {
case c <- log{format, args}:
default: