From f20f78e7ce01f4176d1d3a9e8872084a7f04be66 Mon Sep 17 00:00:00 2001 From: Mikhail Faraponov <11322032+moredure@users.noreply.github.com> Date: Sat, 2 Apr 2022 20:42:49 +0300 Subject: [PATCH] Use type switch with assignment syntax --- notification.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notification.go b/notification.go index 09abe0d5..69bf312d 100644 --- a/notification.go +++ b/notification.go @@ -137,12 +137,12 @@ type Notification struct { // MarshalJSON converts the notification payload to JSON. func (n *Notification) MarshalJSON() ([]byte, error) { - switch n.Payload.(type) { + switch payload := n.Payload.(type) { case string: - return []byte(n.Payload.(string)), nil + return []byte(payload), nil case []byte: - return n.Payload.([]byte), nil + return payload, nil default: - return json.Marshal(n.Payload) + return json.Marshal(payload) } }