about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2024-02-24 21:52:12 +0100
committerLeah Neukirchen <leah@vuxu.org>2024-02-24 21:52:12 +0100
commita9999bbd89b8f6d60acf4f88d0fd1c08a5c023e6 (patch)
tree17852fa6514f06c3b14a7b9c086e319d08693f58
parenta6961b852f884698eb8b0aca778b7001a6b4baa2 (diff)
downloadhtping-a9999bbd89b8f6d60acf4f88d0fd1c08a5c023e6.tar.gz
htping-a9999bbd89b8f6d60acf4f88d0fd1c08a5c023e6.tar.xz
htping-a9999bbd89b8f6d60acf4f88d0fd1c08a5c023e6.zip
add to waitgroup exactly before spawning the goroutine
-rw-r--r--htping.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/htping.go b/htping.go
index 11f0096..83b69fa 100644
--- a/htping.go
+++ b/htping.go
@@ -383,8 +383,8 @@ func main() {
 
 	results := make(chan result)
 
+	wg.Add(1)
 	go func() {
-		wg.Add(1)
 		defer wg.Done()
 		stats(ctx, results)
 	}()
@@ -392,8 +392,6 @@ func main() {
 	count := 0
 
 	for _, u := range args {
-		wg.Add(1)
-
 		u := u
 
 		parsedURL, err := url.ParseRequestURI(u)
@@ -413,6 +411,7 @@ func main() {
 
 		fmt.Printf("%s %s\n", method, u)
 
+		wg.Add(1)
 		go func() {
 			myTransport := newTransport(parsedURL.Hostname())
 			defer wg.Done()