Chore: support MarshalYAML to some config filed (#581)
This commit is contained in:
parent
9471d80785
commit
082847b403
3 changed files with 12 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue