From b5c1b6e635d4505f12da801aa0736888b2f647d0 Mon Sep 17 00:00:00 2001 From: Tevin Zhang Date: Sat, 15 May 2021 19:31:34 +0800 Subject: [PATCH] Reduce exit point --- bool.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bool.go b/bool.go index 90e903c..714da92 100644 --- a/bool.go +++ b/bool.go @@ -83,10 +83,10 @@ func (ab *AtomicBool) MarshalJSON() ([]byte, error) { // NOTE: There's no lock during the process, usually it shouldn't be called with other methods in parallel. func (ab *AtomicBool) UnmarshalJSON(b []byte) error { var v bool - if err := json.Unmarshal(b, &v); err != nil { - return err - } + err := json.Unmarshal(b, &v) - ab.SetTo(v) - return nil + if err == nil { + ab.SetTo(v) + } + return err }