Guarantee that (*Response).Body is not nil

This commit is contained in:
Adnan Maolood
2021-01-15 15:15:16 -05:00
parent 2b17f3d8eb
commit 31de8d49b0
3 changed files with 17 additions and 6 deletions

View File

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