Chore: use any rather than interface{} (#74066)

This commit is contained in:
Ryan McKinley
2023-08-30 18:46:47 +03:00
committed by GitHub
parent 3e272d2bda
commit 025b2f3011
525 changed files with 2528 additions and 2528 deletions
@@ -51,6 +51,6 @@ func (ffi FakeFileInfo) ModTime() time.Time {
return time.Time{}
}
func (ffi FakeFileInfo) Sys() interface{} {
func (ffi FakeFileInfo) Sys() any {
return nil
}
@@ -465,7 +465,7 @@ func (r *ConflictResolver) showChanges() {
// Formatter make it possible for us to write to terminal and to a file
// with different formats depending on the usecase
type Formatter func(format string, a ...interface{}) string
type Formatter func(format string, a ...any) string
func shouldDiscardBlock(seenUsersInBlock map[string]string, block string, user ConflictingUser) bool {
// loop through users to see if we should skip this block
@@ -95,7 +95,7 @@ func updateRows(session *db.Session, rows []map[string][]byte, passwordFieldName
return 0, fmt.Errorf("%v: %w", "marshaling newSecureJsonData failed", err)
}
newRow := map[string]interface{}{"secure_json_data": data, passwordFieldName: ""}
newRow := map[string]any{"secure_json_data": data, passwordFieldName: ""}
session.Table("data_source")
session.Where("id = ?", string(row["id"]))
// Setting both columns while having value only for secure_json_data should clear the [passwordFieldName] column
@@ -111,20 +111,20 @@ func updateRows(session *db.Session, rows []map[string][]byte, passwordFieldName
return rowsUpdated, nil
}
func getUpdatedSecureJSONData(row map[string][]byte, passwordFieldName string) (map[string]interface{}, error) {
func getUpdatedSecureJSONData(row map[string][]byte, passwordFieldName string) (map[string]any, error) {
encryptedPassword, err := util.Encrypt(row[passwordFieldName], setting.SecretKey)
if err != nil {
return nil, err
}
var secureJSONData map[string]interface{}
var secureJSONData map[string]any
if len(row["secure_json_data"]) > 0 {
if err := json.Unmarshal(row["secure_json_data"], &secureJSONData); err != nil {
return nil, err
}
} else {
secureJSONData = map[string]interface{}{}
secureJSONData = map[string]any{}
}
jsonFieldName := util.ToCamelCase(passwordFieldName)
+8 -8
View File
@@ -8,39 +8,39 @@ var (
debugmode = false
)
func Debug(args ...interface{}) {
func Debug(args ...any) {
if debugmode {
fmt.Print(args...)
}
}
func Debugf(fmtString string, args ...interface{}) {
func Debugf(fmtString string, args ...any) {
if debugmode {
fmt.Printf(fmtString, args...)
}
}
func Error(args ...interface{}) {
func Error(args ...any) {
fmt.Print(args...)
}
func Errorf(fmtString string, args ...interface{}) {
func Errorf(fmtString string, args ...any) {
fmt.Printf(fmtString, args...)
}
func Info(args ...interface{}) {
func Info(args ...any) {
fmt.Print(args...)
}
func Infof(fmtString string, args ...interface{}) {
func Infof(fmtString string, args ...any) {
fmt.Printf(fmtString, args...)
}
func Warn(args ...interface{}) {
func Warn(args ...any) {
fmt.Print(args...)
}
func Warnf(fmtString string, args ...interface{}) {
func Warnf(fmtString string, args ...any) {
fmt.Printf(fmtString, args...)
}
+10 -10
View File
@@ -17,51 +17,51 @@ func New(debugMode bool) *CLILogger {
}
}
func (l *CLILogger) Successf(format string, args ...interface{}) {
func (l *CLILogger) Successf(format string, args ...any) {
fmt.Printf(fmt.Sprintf("%s %s\n\n", color.GreenString("✔"), format), args...)
}
func (l *CLILogger) Failuref(format string, args ...interface{}) {
func (l *CLILogger) Failuref(format string, args ...any) {
fmt.Printf(fmt.Sprintf("%s %s %s\n\n", color.RedString("Error"), color.RedString("✗"), format), args...)
}
func (l *CLILogger) Info(args ...interface{}) {
func (l *CLILogger) Info(args ...any) {
args = append(args, "\n\n")
fmt.Print(args...)
}
func (l *CLILogger) Infof(format string, args ...interface{}) {
func (l *CLILogger) Infof(format string, args ...any) {
fmt.Printf(addNewlines(format), args...)
}
func (l *CLILogger) Debug(args ...interface{}) {
func (l *CLILogger) Debug(args ...any) {
args = append(args, "\n\n")
if l.debugMode {
fmt.Print(color.HiBlueString(fmt.Sprint(args...)))
}
}
func (l *CLILogger) Debugf(format string, args ...interface{}) {
func (l *CLILogger) Debugf(format string, args ...any) {
if l.debugMode {
fmt.Print(color.HiBlueString(fmt.Sprintf(addNewlines(format), args...)))
}
}
func (l *CLILogger) Warn(args ...interface{}) {
func (l *CLILogger) Warn(args ...any) {
args = append(args, "\n\n")
fmt.Print(args...)
}
func (l *CLILogger) Warnf(format string, args ...interface{}) {
func (l *CLILogger) Warnf(format string, args ...any) {
fmt.Printf(addNewlines(format), args...)
}
func (l *CLILogger) Error(args ...interface{}) {
func (l *CLILogger) Error(args ...any) {
args = append(args, "\n\n")
fmt.Print(args...)
}
func (l *CLILogger) Errorf(format string, args ...interface{}) {
func (l *CLILogger) Errorf(format string, args ...any) {
fmt.Printf(addNewlines(format), args...)
}
+1 -1
View File
@@ -16,7 +16,7 @@ type CommandLine interface {
String(name string) string
StringSlice(name string) []string
FlagNames() (names []string)
Generic(name string) interface{}
Generic(name string) any
PluginDirectory() string
PluginRepoURL() string
@@ -75,15 +75,15 @@ func (_m *MockCommandLine) FlagNames() []string {
}
// Generic provides a mock function with given fields: name
func (_m *MockCommandLine) Generic(name string) interface{} {
func (_m *MockCommandLine) Generic(name string) any {
ret := _m.Called(name)
var r0 interface{}
if rf, ok := ret.Get(0).(func(string) interface{}); ok {
var r0 any
if rf, ok := ret.Get(0).(func(string) any); ok {
r0 = rf(name)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(interface{})
r0 = ret.Get(0).(any)
}
}