mirror of
https://github.com/Icinga/icingadb.git
synced 2026-06-09 08:56:54 -04:00
Always use text as paramter name in UnmarshalText()
This commit is contained in:
parent
42935ae962
commit
63b8d98237
4 changed files with 16 additions and 16 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue