From 6ed9a0639407c5820103617ec2fad9aa8b8a9ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 19 Oct 2024 21:07:43 +0800 Subject: [PATCH] Fix rule-set format --- option/rule_set.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/option/rule_set.go b/option/rule_set.go index b6ec113e..d4368de3 100644 --- a/option/rule_set.go +++ b/option/rule_set.go @@ -48,17 +48,6 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error { if r.Tag == "" { return E.New("missing tag") } - if r.Type != C.RuleSetTypeInline { - switch r.Format { - case "": - return E.New("missing format") - case C.RuleSetFormatSource, C.RuleSetFormatBinary: - default: - return E.New("unknown rule-set format: " + r.Format) - } - } else { - r.Format = "" - } var v any switch r.Type { case "", C.RuleSetTypeInline: @@ -71,6 +60,17 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error { default: return E.New("unknown rule-set type: " + r.Type) } + if r.Type != C.RuleSetTypeInline { + switch r.Format { + case "": + return E.New("missing format") + case C.RuleSetFormatSource, C.RuleSetFormatBinary: + default: + return E.New("unknown rule-set format: " + r.Format) + } + } else { + r.Format = "" + } err = UnmarshallExcluded(bytes, (*_RuleSet)(r), v) if err != nil { return err