From 6be4bebc0c3d3779b25445ef44f072bab9180ad4 Mon Sep 17 00:00:00 2001 From: Nicholas Wiersma Date: Fri, 23 Jun 2023 15:41:27 +0200 Subject: [PATCH] chore: switch from `interface{}` to `any` (#1837) --- cmd/proxy/actions/app_proxy.go | 2 +- pkg/config/config_test.go | 4 ++-- pkg/errors/doc.go | 2 +- pkg/errors/errors.go | 2 +- pkg/log/entry.go | 12 ++++++------ pkg/log/format.go | 2 +- pkg/log/log.go | 2 +- pkg/stash/with_redis.go | 2 +- pkg/stash/with_redis_test.go | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/proxy/actions/app_proxy.go b/cmd/proxy/actions/app_proxy.go index 27187f68..0b9cd00d 100644 --- a/cmd/proxy/actions/app_proxy.go +++ b/cmd/proxy/actions/app_proxy.go @@ -133,7 +133,7 @@ type athensLoggerForRedis struct { logger *log.Logger } -func (l *athensLoggerForRedis) Printf(ctx context.Context, format string, v ...interface{}) { +func (l *athensLoggerForRedis) Printf(ctx context.Context, format string, v ...any) { l.logger.WithContext(ctx).Printf(format, v...) } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 58ce8c9c..9cd31e0c 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -22,9 +22,9 @@ func testConfigFile(t *testing.T) (testConfigFile string) { return testConfigFile } -func compareConfigs(parsedConf *Config, expConf *Config, t *testing.T, ignoreTypes ...interface{}) { +func compareConfigs(parsedConf *Config, expConf *Config, t *testing.T, ignoreTypes ...any) { t.Helper() - opts := cmpopts.IgnoreTypes(append([]interface{}{Index{}}, ignoreTypes...)...) + opts := cmpopts.IgnoreTypes(append([]any{Index{}}, ignoreTypes...)...) eq := cmp.Equal(parsedConf, expConf, opts) if !eq { diff := cmp.Diff(parsedConf, expConf, opts) diff --git a/pkg/errors/doc.go b/pkg/errors/doc.go index 77292436..8d9685ca 100644 --- a/pkg/errors/doc.go +++ b/pkg/errors/doc.go @@ -11,7 +11,7 @@ // the logger's SystemError method, although it accepts any type of error, // it knows how to deal with errors constructed from this package in a debuggable way. // To construct an Athens error, call the errors.E function. The E function takes -// an Op and a variadic interface{}, but the values of the Error struct are what you can +// an Op and a variadic of any, but the values of the Error struct are what you can // pass to it. Values such as the error Kind, Module, Version, Error Message, // and Seveirty (seriousness of an error) are all optional. The only truly required value is // the errors.Op so you can construct a traceable stack that leads to where diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index 4f922034..87af8ea7 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -88,7 +88,7 @@ type V string // an error or a string to describe what exactly went wrong. // You can optionally pass a Logrus severity to indicate // the log level of an error based on the context it was constructed in. -func E(op Op, args ...interface{}) error { +func E(op Op, args ...any) error { e := Error{Op: op} if len(args) == 0 { msg := "errors.E called with 0 args" diff --git a/pkg/log/entry.go b/pkg/log/entry.go index ef21480e..e7053bf7 100644 --- a/pkg/log/entry.go +++ b/pkg/log/entry.go @@ -12,13 +12,13 @@ import ( // Fields are being overwritten. type Entry interface { // Basic Logging Operation - Debugf(format string, args ...interface{}) - Infof(format string, args ...interface{}) - Warnf(format string, args ...interface{}) - Errorf(format string, args ...interface{}) + Debugf(format string, args ...any) + Infof(format string, args ...any) + Warnf(format string, args ...any) + Errorf(format string, args ...any) // Attach contextual information to the logging entry - WithFields(fields map[string]interface{}) Entry + WithFields(fields map[string]any) Entry // SystemErr is a method that disects the error // and logs the appropriate level and fields for it. @@ -29,7 +29,7 @@ type entry struct { *logrus.Entry } -func (e *entry) WithFields(fields map[string]interface{}) Entry { +func (e *entry) WithFields(fields map[string]any) Entry { ent := e.Entry.WithFields(fields) return &entry{ent} } diff --git a/pkg/log/format.go b/pkg/log/format.go index f1e69d06..30d64a46 100644 --- a/pkg/log/format.go +++ b/pkg/log/format.go @@ -31,7 +31,7 @@ const lightGrey = 0xffccc func (devFormatter) Format(e *logrus.Entry) ([]byte, error) { var buf bytes.Buffer - var sprintf func(format string, a ...interface{}) string + var sprintf func(format string, a ...any) string switch e.Level { case logrus.DebugLevel: sprintf = color.New(lightGrey).Sprintf diff --git a/pkg/log/log.go b/pkg/log/log.go index 1c55d3e2..1139e2a5 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -35,7 +35,7 @@ func (l *Logger) SystemErr(err error) { } // WithFields Entry implementation. -func (l *Logger) WithFields(fields map[string]interface{}) Entry { +func (l *Logger) WithFields(fields map[string]any) Entry { e := l.Logger.WithFields(fields) return &entry{e} diff --git a/pkg/stash/with_redis.go b/pkg/stash/with_redis.go index 64e8d1de..ff32fb89 100644 --- a/pkg/stash/with_redis.go +++ b/pkg/stash/with_redis.go @@ -15,7 +15,7 @@ import ( // RedisLogger mirrors github.com/go-redis/redis/v8/internal.Logging. type RedisLogger interface { - Printf(ctx context.Context, format string, v ...interface{}) + Printf(ctx context.Context, format string, v ...any) } // WithRedisLock returns a distributed singleflight diff --git a/pkg/stash/with_redis_test.go b/pkg/stash/with_redis_test.go index c4cab31d..ba49dba2 100644 --- a/pkg/stash/with_redis_test.go +++ b/pkg/stash/with_redis_test.go @@ -20,7 +20,7 @@ type testingRedisLogger struct { t *testing.T } -func (l *testingRedisLogger) Printf(ctx context.Context, format string, v ...interface{}) { +func (l *testingRedisLogger) Printf(ctx context.Context, format string, v ...any) { l.t.Logf(format, v...) }