From 5dbf67f2f9ed4be0693260fa281e24d8fad00613 Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 24 Mar 2025 09:29:19 +0800 Subject: [PATCH] optimize code --- helper/httptool/http.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helper/httptool/http.go b/helper/httptool/http.go index 0b98b68..678ec1b 100644 --- a/helper/httptool/http.go +++ b/helper/httptool/http.go @@ -37,6 +37,9 @@ func GetString(u string, q map[string]any, a ...any) (r string, code int, err er func Get(u string, q map[string]any, a ...any) (res *http.Response, err error) { cli, req, err := BuildClient(u, "get", q, a...) + if err != nil { + return + } res, err = cli.Do(req) return } @@ -109,6 +112,9 @@ func BuildClient(u, method string, q map[string]any, a ...any) (res *http.Client // types 1 x-www-form-urlencoded, 2 form-data, 3 json, 4 binary func Post(u string, types int, form map[string]any, a ...any) (res *http.Response, err error) { cli, req, err := PostClient(u, types, form, a...) + if err != nil { + return + } res, err = cli.Do(req) return }