From 082847b40384c037842fb2ea95b24107dda58903 Mon Sep 17 00:00:00 2001 From: Kaming Chan Date: Sun, 15 Mar 2020 19:40:39 +0800 Subject: [PATCH] Chore: support MarshalYAML to some config filed (#581) --- dns/util.go | 5 ++--- log/level.go | 5 +++++ tunnel/mode.go | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dns/util.go b/dns/util.go index 00ac4566..ad52f051 100644 --- a/dns/util.go +++ b/dns/util.go @@ -11,7 +11,6 @@ import ( "github.com/Dreamacro/clash/log" D "github.com/miekg/dns" - yaml "gopkg.in/yaml.v2" ) var ( @@ -46,8 +45,8 @@ func (e *EnhancedMode) UnmarshalYAML(unmarshal func(interface{}) error) error { } // MarshalYAML serialize EnhancedMode with yaml -func (e EnhancedMode) MarshalYAML() ([]byte, error) { - return yaml.Marshal(e.String()) +func (e EnhancedMode) MarshalYAML() (interface{}, error) { + return e.String(), nil } // UnmarshalJSON unserialize EnhancedMode with json diff --git a/log/level.go b/log/level.go index e95e36d2..ea223c12 100644 --- a/log/level.go +++ b/log/level.go @@ -55,6 +55,11 @@ func (l LogLevel) MarshalJSON() ([]byte, error) { return json.Marshal(l.String()) } +// MarshalYAML serialize LogLevel with yaml +func (l LogLevel) MarshalYAML() (interface{}, error) { + return l.String(), nil +} + func (l LogLevel) String() string { switch l { case INFO: diff --git a/tunnel/mode.go b/tunnel/mode.go index b00b73ab..655c9f57 100644 --- a/tunnel/mode.go +++ b/tunnel/mode.go @@ -51,6 +51,11 @@ func (m TunnelMode) MarshalJSON() ([]byte, error) { return json.Marshal(m.String()) } +// MarshalYAML serialize TunnelMode with yaml +func (m TunnelMode) MarshalYAML() (interface{}, error) { + return m.String(), nil +} + func (m TunnelMode) String() string { switch m { case Global: