From 2889ff3a2b77f25285d8a6893f1a39e86ef0a58e Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Thu, 8 Dec 2022 00:59:50 +0100 Subject: [PATCH] fix memory leak From https://pkg.go.dev/net/http > The client must close the response body when finished with it --- collector.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/collector.go b/collector.go index 7fb1a83..56b5cc5 100644 --- a/collector.go +++ b/collector.go @@ -93,6 +93,7 @@ func fetchInstance() (Instance, error) { if err != nil { return instance, err } + defer res.Body.Close() err = json.NewDecoder(res.Body).Decode(&instance) return instance, err @@ -104,7 +105,8 @@ func fetchActivity() (Activities, error) { if err != nil { return activities, err } - + defer res.Body.Close() + err = json.NewDecoder(res.Body).Decode(&activities) return activities, err }