From 1b208a369ef25de953b5825f370d619638dcf9bd Mon Sep 17 00:00:00 2001 From: dylanyang Date: Thu, 20 Jun 2024 20:19:07 +0800 Subject: [PATCH] update defer --- common/price_compoent/price_util.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/price_compoent/price_util.go b/common/price_compoent/price_util.go index 2d797b1..287588e 100644 --- a/common/price_compoent/price_util.go +++ b/common/price_compoent/price_util.go @@ -71,10 +71,8 @@ func GetPriceUsd(tokenType global_const.TokenType) (float64, error) { bodystr := string(body) strarr := strings.Split(bodystr, ":") usdstr := strings.TrimRight(strarr[2], "}}") - err := res.Body.Close() - if err != nil { - logrus.Errorf("close body error: %v", err) - } + defer res.Body.Close() + return strconv.ParseFloat(usdstr, 64) }