fix memory leak
From https://pkg.go.dev/net/http > The client must close the response body when finished with it
This commit is contained in:
parent
9d520848a7
commit
2889ff3a2b
1 changed files with 3 additions and 1 deletions
|
@ -93,6 +93,7 @@ func fetchInstance() (Instance, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return instance, err
|
return instance, err
|
||||||
}
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
err = json.NewDecoder(res.Body).Decode(&instance)
|
err = json.NewDecoder(res.Body).Decode(&instance)
|
||||||
return instance, err
|
return instance, err
|
||||||
|
@ -104,6 +105,7 @@ func fetchActivity() (Activities, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return activities, err
|
return activities, err
|
||||||
}
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
err = json.NewDecoder(res.Body).Decode(&activities)
|
err = json.NewDecoder(res.Body).Decode(&activities)
|
||||||
return activities, err
|
return activities, err
|
||||||
|
|
Loading…
Reference in a new issue