Don't guarantee that (*Response).Body is always non-nil

This commit is contained in:
Adnan Maolood
2020-11-08 18:38:08 -05:00
parent 6b3cf1314b
commit 5332dc6280
3 changed files with 5 additions and 7 deletions

View File

@@ -80,9 +80,9 @@ func main() {
fmt.Println(err)
os.Exit(1)
}
defer resp.Body.Close()
if resp.Status.Class() == gemini.StatusClassSuccess {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)