From 2f963d70e741a6d22ebafdb5f70c13ba860c9788 Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Wed, 29 Nov 2023 20:21:18 +0100 Subject: [PATCH] Add linting for `any` (#2893) Add gofmt rules to make sure `interface{}` is not used but only `any`. --- .golangci.yml | 3 +++ server/store/datastore/migration/logger.go | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 96e129200..e2bec6801 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,9 @@ linters-settings: gofmt: simplify: true + rewrite-rules: + - pattern: interface{} + replacement: any misspell: locale: US gofumpt: diff --git a/server/store/datastore/migration/logger.go b/server/store/datastore/migration/logger.go index a9493307d..2294d6957 100644 --- a/server/store/datastore/migration/logger.go +++ b/server/store/datastore/migration/logger.go @@ -22,34 +22,34 @@ import ( type xormigrateLogger struct{} -func (l *xormigrateLogger) Debug(v ...interface{}) { +func (l *xormigrateLogger) Debug(v ...any) { log.Debug().Msg(fmt.Sprint(v...)) } -func (l *xormigrateLogger) Debugf(format string, v ...interface{}) { +func (l *xormigrateLogger) Debugf(format string, v ...any) { log.Debug().Msgf(format, v...) } -func (l *xormigrateLogger) Info(v ...interface{}) { +func (l *xormigrateLogger) Info(v ...any) { log.Info().Msg(fmt.Sprint(v...)) } -func (l *xormigrateLogger) Infof(format string, v ...interface{}) { +func (l *xormigrateLogger) Infof(format string, v ...any) { log.Info().Msgf(format, v...) } -func (l *xormigrateLogger) Warn(v ...interface{}) { +func (l *xormigrateLogger) Warn(v ...any) { log.Warn().Msg(fmt.Sprint(v...)) } -func (l *xormigrateLogger) Warnf(format string, v ...interface{}) { +func (l *xormigrateLogger) Warnf(format string, v ...any) { log.Warn().Msgf(format, v...) } -func (l *xormigrateLogger) Error(v ...interface{}) { +func (l *xormigrateLogger) Error(v ...any) { log.Error().Msg(fmt.Sprint(v...)) } -func (l *xormigrateLogger) Errorf(format string, v ...interface{}) { +func (l *xormigrateLogger) Errorf(format string, v ...any) { log.Error().Msgf(format, v...) }