From 3928da203cae99fe5c209263582b86751c5f68d6 Mon Sep 17 00:00:00 2001 From: Akenaide <kevinms1@gmail.com> Date: Tue, 30 Jul 2019 02:58:26 +0200 Subject: [PATCH] Fix: error with async (again) Process was finishing early if the first request was a 404. WaitGroup was not increment so it exit imediatly. --- cmd/fetch.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/fetch.go b/cmd/fetch.go index e18419c..8c839b2 100644 --- a/cmd/fetch.go +++ b/cmd/fetch.go @@ -48,15 +48,16 @@ func worker(id int, furni furniture, respChannel chan<- *http.Response) { return } log.Println("ID :", id, "Fetch page : ", link, "with params : ", furni.Values) + furni.Wg.Add(1) resp, err := furni.Client.PostForm(link, furni.Values) if err != nil { log.Fatal(err) } if resp.StatusCode == 404 { *furni.Kanseru = true + furni.Wg.Done() } else { respChannel <- resp - furni.Wg.Add(1) } }