From c72e692be33d5ab2884db6e2f1cf027f150a108a Mon Sep 17 00:00:00 2001 From: Keuin Date: Wed, 7 Sep 2022 10:18:55 +0800 Subject: Bugfix: callGet[T] will panic if the request is unsuccessful --- bilibili/request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bilibili/request.go') diff --git a/bilibili/request.go b/bilibili/request.go index cb989a7..c31cf75 100644 --- a/bilibili/request.go +++ b/bilibili/request.go @@ -38,11 +38,11 @@ func callGet[T BaseResponse[V], V any](b Bilibili, url string) (resp T, err erro } r, err := b.http.Do(req) - defer func() { _ = r.Body.Close() }() if err != nil { logger.Printf("ERROR: HTTP Request failed on API %v: %v", url, err) return } + defer func() { _ = r.Body.Close() }() err = validateHttpStatus(r) if err != nil { -- cgit v1.2.3