From 5332dc628043a5c0d18652ebf4b89576de7af653 Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Sun, 8 Nov 2020 18:38:08 -0500 Subject: Don't guarantee that (*Response).Body is always non-nil --- doc.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'doc.go') diff --git a/doc.go b/doc.go index 944adbb..ea988ef 100644 --- a/doc.go +++ b/doc.go @@ -7,7 +7,10 @@ Get makes a Gemini request: if err != nil { // handle error } - defer resp.Body.Close() + if resp.Status.Class() == gemini.StatusClassSucess { + defer resp.Body.Close() + // ... + } // ... For control over client behavior, create a Client: -- cgit v1.2.3