From 63b8d98237e0bae10995a7b9374fed83ef00746f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 10 Jun 2021 14:02:48 +0200 Subject: [PATCH] Always use text as paramter name in UnmarshalText() --- pkg/types/acknowledgement_state.go | 4 ++-- pkg/types/comment_type.go | 12 ++++++------ pkg/types/notification_type.go | 12 ++++++------ pkg/types/state_type.go | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/types/acknowledgement_state.go b/pkg/types/acknowledgement_state.go index 7e41dc9b..5bff6137 100644 --- a/pkg/types/acknowledgement_state.go +++ b/pkg/types/acknowledgement_state.go @@ -12,8 +12,8 @@ import ( type AcknowledgementState uint8 // UnmarshalText implements the encoding.TextUnmarshaler interface. -func (as *AcknowledgementState) UnmarshalText(bytes []byte) error { - return as.UnmarshalJSON(bytes) +func (as *AcknowledgementState) UnmarshalText(text []byte) error { + return as.UnmarshalJSON(text) } // UnmarshalJSON implements the json.Unmarshaler interface. diff --git a/pkg/types/comment_type.go b/pkg/types/comment_type.go index 4eb65caf..5e88e47c 100644 --- a/pkg/types/comment_type.go +++ b/pkg/types/comment_type.go @@ -29,22 +29,22 @@ func (ct *CommentType) UnmarshalJSON(bytes []byte) error { } // UnmarshalText implements the encoding.TextUnmarshaler interface. -func (ct *CommentType) UnmarshalText(bytes []byte) error { - text := string(bytes) +func (ct *CommentType) UnmarshalText(text []byte) error { + s := string(text) - i, err := strconv.ParseUint(text, 10, 64) + i, err := strconv.ParseUint(s, 10, 64) if err != nil { - return internal.CantParseUint64(err, text) + return internal.CantParseUint64(err, s) } c := CommentType(i) if uint64(c) != i { // Truncated due to above cast, obviously too high - return badCommentType(text) + return badCommentType(s) } if _, ok := commentTypes[c]; !ok { - return badCommentType(text) + return badCommentType(s) } *ct = c diff --git a/pkg/types/notification_type.go b/pkg/types/notification_type.go index 872d5a13..f2980f4e 100644 --- a/pkg/types/notification_type.go +++ b/pkg/types/notification_type.go @@ -12,22 +12,22 @@ import ( type NotificationType uint16 // UnmarshalText implements the encoding.TextUnmarshaler interface. -func (nt *NotificationType) UnmarshalText(bytes []byte) error { - text := string(bytes) +func (nt *NotificationType) UnmarshalText(text []byte) error { + s := string(text) - i, err := strconv.ParseUint(text, 10, 64) + i, err := strconv.ParseUint(s, 10, 64) if err != nil { - return internal.CantParseUint64(err, text) + return internal.CantParseUint64(err, s) } n := NotificationType(i) if uint64(n) != i { // Truncated due to above cast, obviously too high - return badNotificationType(text) + return badNotificationType(s) } if _, ok := notificationTypes[n]; !ok { - return badNotificationType(text) + return badNotificationType(s) } *nt = n diff --git a/pkg/types/state_type.go b/pkg/types/state_type.go index c04f7f2e..8a24819e 100644 --- a/pkg/types/state_type.go +++ b/pkg/types/state_type.go @@ -12,8 +12,8 @@ import ( type StateType uint8 // UnmarshalText implements the encoding.TextUnmarshaler interface. -func (st *StateType) UnmarshalText(bytes []byte) error { - return st.UnmarshalJSON(bytes) +func (st *StateType) UnmarshalText(text []byte) error { + return st.UnmarshalJSON(text) } // UnmarshalJSON implements the json.Unmarshaler interface.