mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
types.NotificationTypes: Implement UnmarshalText()
This commit is contained in:
parent
9e3a8b4d1d
commit
26c889ad66
1 changed files with 10 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ package types
|
|||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
|
@ -29,6 +30,11 @@ func (nt *NotificationTypes) UnmarshalJSON(bytes []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the encoding.TextUnmarshaler interface.
|
||||
func (nt *NotificationTypes) UnmarshalText(text []byte) error {
|
||||
return nt.UnmarshalJSON(text)
|
||||
}
|
||||
|
||||
// Value implements the driver.Valuer interface.
|
||||
func (nt NotificationTypes) Value() (driver.Value, error) {
|
||||
if nt&^allNotificationTypes == 0 {
|
||||
|
|
@ -73,7 +79,8 @@ var allNotificationTypes = func() NotificationTypes {
|
|||
|
||||
// Assert interface compliance.
|
||||
var (
|
||||
_ error = BadNotificationTypes{}
|
||||
_ json.Unmarshaler = (*NotificationTypes)(nil)
|
||||
_ driver.Valuer = NotificationTypes(0)
|
||||
_ error = BadNotificationTypes{}
|
||||
_ json.Unmarshaler = (*NotificationTypes)(nil)
|
||||
_ encoding.TextUnmarshaler = (*NotificationTypes)(nil)
|
||||
_ driver.Valuer = NotificationTypes(0)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue