diff --git a/cmd/config_loader.go b/cmd/config_loader.go index 6d984840..9f0a5769 100644 --- a/cmd/config_loader.go +++ b/cmd/config_loader.go @@ -40,7 +40,7 @@ func initConfigFileInputSourceFunc(configFlag string, flags []cli.Flag, next cli // This function also maps aliases, so a .yml file can contain short options, or options with underscores // instead of dashes. See https://github.com/binwiederhier/ntfy/issues/255. func newYamlSourceFromFile(file string, flags []cli.Flag) (altsrc.InputSourceContext, error) { - var rawConfig map[interface{}]interface{} + var rawConfig map[any]any b, err := os.ReadFile(file) if err != nil { return nil, err diff --git a/log/log.go b/log/log.go index 5dac2327..4061921d 100644 --- a/log/log.go +++ b/log/log.go @@ -40,32 +40,32 @@ var ( ) // Trace prints the given message, if the current log level is TRACE -func Trace(message string, v ...interface{}) { +func Trace(message string, v ...any) { logIf(TraceLevel, message, v...) } // Debug prints the given message, if the current log level is DEBUG or lower -func Debug(message string, v ...interface{}) { +func Debug(message string, v ...any) { logIf(DebugLevel, message, v...) } // Info prints the given message, if the current log level is INFO or lower -func Info(message string, v ...interface{}) { +func Info(message string, v ...any) { logIf(InfoLevel, message, v...) } // Warn prints the given message, if the current log level is WARN or lower -func Warn(message string, v ...interface{}) { +func Warn(message string, v ...any) { logIf(WarnLevel, message, v...) } // Error prints the given message, if the current log level is ERROR or lower -func Error(message string, v ...interface{}) { +func Error(message string, v ...any) { logIf(ErrorLevel, message, v...) } // Fatal prints the given message, and exits the program -func Fatal(v ...interface{}) { +func Fatal(v ...any) { log.Fatalln(v...) } @@ -122,7 +122,7 @@ func IsDebug() bool { return Loggable(DebugLevel) } -func logIf(l Level, message string, v ...interface{}) { +func logIf(l Level, message string, v ...any) { if CurrentLevel() <= l { log.Printf(l.String()+" "+message, v...) } diff --git a/server/errors.go b/server/errors.go index 460138a7..63dffeef 100644 --- a/server/errors.go +++ b/server/errors.go @@ -23,7 +23,7 @@ func (e errHTTP) JSON() string { return string(b) } -func wrapErrHTTP(err *errHTTP, message string, args ...interface{}) *errHTTP { +func wrapErrHTTP(err *errHTTP, message string, args ...any) *errHTTP { return &errHTTP{ Code: err.Code, HTTPCode: err.HTTPCode, diff --git a/server/server_firebase.go b/server/server_firebase.go index 15d78952..ab9d7fad 100644 --- a/server/server_firebase.go +++ b/server/server_firebase.go @@ -217,7 +217,7 @@ func maybeTruncateFCMMessage(m *messaging.Message) *messaging.Message { // We must set the Alert struct ("alert"), and we need to set MutableContent ("mutable-content"), so the Notification Service // Extension in iOS can modify the message. func createAPNSAlertConfig(m *message, data map[string]string) *messaging.APNSConfig { - apnsData := make(map[string]interface{}) + apnsData := make(map[string]any) for k, v := range data { apnsData[k] = v } @@ -241,7 +241,7 @@ func createAPNSAlertConfig(m *message, data map[string]string) *messaging.APNSCo // // See https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app func createAPNSBackgroundConfig(data map[string]string) *messaging.APNSConfig { - apnsData := make(map[string]interface{}) + apnsData := make(map[string]any) for k, v := range data { apnsData[k] = v } diff --git a/server/server_firebase_test.go b/server/server_firebase_test.go index 8d898db1..3e034c06 100644 --- a/server/server_firebase_test.go +++ b/server/server_firebase_test.go @@ -71,7 +71,7 @@ func TestToFirebaseMessage_Keepalive(t *testing.T) { Aps: &messaging.Aps{ ContentAvailable: true, }, - CustomData: map[string]interface{}{ + CustomData: map[string]any{ "id": m.ID, "time": fmt.Sprintf("%d", m.Time), "event": m.Event, @@ -102,7 +102,7 @@ func TestToFirebaseMessage_Open(t *testing.T) { Aps: &messaging.Aps{ ContentAvailable: true, }, - CustomData: map[string]interface{}{ + CustomData: map[string]any{ "id": m.ID, "time": fmt.Sprintf("%d", m.Time), "event": m.Event, @@ -166,7 +166,7 @@ func TestToFirebaseMessage_Message_Normal_Allowed(t *testing.T) { Body: "this is a message", }, }, - CustomData: map[string]interface{}{ + CustomData: map[string]any{ "id": m.ID, "time": fmt.Sprintf("%d", m.Time), "event": "message", @@ -242,7 +242,7 @@ func TestToFirebaseMessage_PollRequest(t *testing.T) { Body: "New message", }, }, - CustomData: map[string]interface{}{ + CustomData: map[string]any{ "id": m.ID, "time": fmt.Sprintf("%d", m.Time), "event": "poll_request", diff --git a/util/gzip_handler.go b/util/gzip_handler.go index 637077c7..9b30fa8a 100644 --- a/util/gzip_handler.go +++ b/util/gzip_handler.go @@ -30,7 +30,7 @@ func Gzip(next http.Handler) http.Handler { } var gzPool = sync.Pool{ - New: func() interface{} { + New: func() any { w := gzip.NewWriter(io.Discard) return w }, diff --git a/util/util.go b/util/util.go index 3f65c8b7..05079180 100644 --- a/util/util.go +++ b/util/util.go @@ -241,7 +241,7 @@ func BasicAuth(user, pass string) string { // MaybeMarshalJSON returns a JSON string of the given object, or "" if serialization failed. // This is useful for logging purposes where a failure doesn't matter that much. -func MaybeMarshalJSON(v interface{}) string { +func MaybeMarshalJSON(v any) string { jsonBytes, err := json.MarshalIndent(v, "", " ") if err != nil { return ""