ing
This commit is contained in:
parent
b02776ec03
commit
f6eb351409
|
@ -5,37 +5,37 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiscoveryModeEnum int
|
type DiscoveryModeType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DiscoveryModeEnumPrivileged DiscoveryModeEnum = iota + 1
|
DiscoveryModeTypePrivileged DiscoveryModeType = iota + 1
|
||||||
DiscoveryModeEnumUnprivileged
|
DiscoveryModeTypeUnprivileged
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
discoveryModeEnumID = map[DiscoveryModeEnum]string{
|
discoveryModeTypeID = map[DiscoveryModeType]string{
|
||||||
DiscoveryModeEnumPrivileged: "Privileged",
|
DiscoveryModeTypePrivileged: "Privileged",
|
||||||
DiscoveryModeEnumUnprivileged: "Unprivileged",
|
DiscoveryModeTypeUnprivileged: "Unprivileged",
|
||||||
}
|
}
|
||||||
|
|
||||||
discoveryModeEnumName = map[string]DiscoveryModeEnum{
|
discoveryModeTypeName = map[string]DiscoveryModeType{
|
||||||
"Privileged": DiscoveryModeEnumPrivileged,
|
"Privileged": DiscoveryModeTypePrivileged,
|
||||||
"Unprivileged": DiscoveryModeEnumUnprivileged,
|
"Unprivileged": DiscoveryModeTypeUnprivileged,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e DiscoveryModeEnum) String() string {
|
func (e DiscoveryModeType) String() string {
|
||||||
return discoveryModeEnumID[e]
|
return discoveryModeTypeID[e]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *DiscoveryModeEnum) MarshalJSON() ([]byte, error) {
|
func (e *DiscoveryModeType) MarshalJSON() ([]byte, error) {
|
||||||
buffer := bytes.NewBufferString(`"`)
|
buffer := bytes.NewBufferString(`"`)
|
||||||
buffer.WriteString(discoveryModeEnumID[*e])
|
buffer.WriteString(discoveryModeTypeID[*e])
|
||||||
buffer.WriteString(`"`)
|
buffer.WriteString(`"`)
|
||||||
return buffer.Bytes(), nil
|
return buffer.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *DiscoveryModeEnum) UnmarshalJSON(b []byte) error {
|
func (e *DiscoveryModeType) UnmarshalJSON(b []byte) error {
|
||||||
// unmarshal as string
|
// unmarshal as string
|
||||||
var s string
|
var s string
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
@ -43,6 +43,6 @@ func (e *DiscoveryModeEnum) UnmarshalJSON(b []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// lookup value
|
// lookup value
|
||||||
*e = discoveryModeEnumName[s]
|
*e = discoveryModeTypeName[s]
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user