Skip to content

Commit

Permalink
Fix: error with async (again)
Browse files Browse the repository at this point in the history
Process was finishing early if the first request was a 404. WaitGroup
was not increment so it exit imediatly.
  • Loading branch information
Akenaide committed Jul 30, 2019
1 parent 467b58b commit 3928da2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
Expand Down

0 comments on commit 3928da2

Please sign in to comment.