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

@@ -515,7 +515,7 @@ func (l *Logger) encode(buf []byte, level int) []byte {
now := l.timeNow()
obj := make(map[string]interface{})
obj := make(map[string]any)
if err := json.Unmarshal(buf, &obj); err != nil {
for k := range obj {
delete(obj, k)
@@ -553,7 +553,7 @@ func (l *Logger) encode(buf []byte, level int) []byte {
}
// Logf logs to l using the provided fmt-style format and optional arguments.
func (l *Logger) Logf(format string, args ...interface{}) {
func (l *Logger) Logf(format string, args ...any) {
fmt.Fprintf(l, format, args...)
}

View File

@@ -128,7 +128,7 @@ func TestEncodeAndUploadMessages(t *testing.T) {
ltail, ok := data["logtail"]
if ok {
logtailmap := ltail.(map[string]interface{})
logtailmap := ltail.(map[string]any)
_, ok = logtailmap["client_time"]
if !ok {
t.Errorf("%s: no client_time present", tt.name)
@@ -317,9 +317,9 @@ func TestPublicIDUnmarshalText(t *testing.T) {
}
}
func unmarshalOne(t *testing.T, body []byte) map[string]interface{} {
func unmarshalOne(t *testing.T, body []byte) map[string]any {
t.Helper()
var entries []map[string]interface{}
var entries []map[string]any
err := json.Unmarshal(body, &entries)
if err != nil {
t.Error(err)