Close resources as soon as possible, instead of using defer() in a loop

So that resources can be freed as soon as they're not used anymore, instead of
waiting for the two nested loops to finish.
This commit is contained in:
jvoisin 2024-02-29 00:30:54 +01:00 committed by Frédéric Guillot
parent c4e5dad549
commit 543a690bfd

View file

@ -232,9 +232,10 @@ func (f *SubscriptionFinder) FindSubscriptionsFromWellKnownURLs(websiteURL strin
f.requestBuilder.WithoutRedirects()
responseHandler := fetcher.NewResponseHandler(f.requestBuilder.ExecuteRequest(fullURL))
defer responseHandler.Close()
localizedError := responseHandler.LocalizedError()
responseHandler.Close()
if localizedError := responseHandler.LocalizedError(); localizedError != nil {
if localizedError != nil {
slog.Debug("Unable to subscribe", slog.String("fullURL", fullURL), slog.Any("error", localizedError.Error()))
continue
}