From f6eb351409e9f111e950121c1b3d209d79833767 Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 17 Sep 2018 15:29:47 +0900 Subject: [PATCH] ing --- discovery/discovery.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/discovery/discovery.go b/discovery/discovery.go index 56c488f..65eebcb 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -5,37 +5,37 @@ import ( "encoding/json" ) -type DiscoveryModeEnum int +type DiscoveryModeType int const ( - DiscoveryModeEnumPrivileged DiscoveryModeEnum = iota + 1 - DiscoveryModeEnumUnprivileged + DiscoveryModeTypePrivileged DiscoveryModeType = iota + 1 + DiscoveryModeTypeUnprivileged ) var ( - discoveryModeEnumID = map[DiscoveryModeEnum]string{ - DiscoveryModeEnumPrivileged: "Privileged", - DiscoveryModeEnumUnprivileged: "Unprivileged", + discoveryModeTypeID = map[DiscoveryModeType]string{ + DiscoveryModeTypePrivileged: "Privileged", + DiscoveryModeTypeUnprivileged: "Unprivileged", } - discoveryModeEnumName = map[string]DiscoveryModeEnum{ - "Privileged": DiscoveryModeEnumPrivileged, - "Unprivileged": DiscoveryModeEnumUnprivileged, + discoveryModeTypeName = map[string]DiscoveryModeType{ + "Privileged": DiscoveryModeTypePrivileged, + "Unprivileged": DiscoveryModeTypeUnprivileged, } ) -func (e DiscoveryModeEnum) String() string { - return discoveryModeEnumID[e] +func (e DiscoveryModeType) String() string { + return discoveryModeTypeID[e] } -func (e *DiscoveryModeEnum) MarshalJSON() ([]byte, error) { +func (e *DiscoveryModeType) MarshalJSON() ([]byte, error) { buffer := bytes.NewBufferString(`"`) - buffer.WriteString(discoveryModeEnumID[*e]) + buffer.WriteString(discoveryModeTypeID[*e]) buffer.WriteString(`"`) return buffer.Bytes(), nil } -func (e *DiscoveryModeEnum) UnmarshalJSON(b []byte) error { +func (e *DiscoveryModeType) UnmarshalJSON(b []byte) error { // unmarshal as string var s string err := json.Unmarshal(b, &s) @@ -43,6 +43,6 @@ func (e *DiscoveryModeEnum) UnmarshalJSON(b []byte) error { return err } // lookup value - *e = discoveryModeEnumName[s] + *e = discoveryModeTypeName[s] return nil }