From aefabe683f3fba846707a9f3a5e11f9b4be16990 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Mon, 3 May 2021 10:23:03 +0200 Subject: [PATCH] fix(client/snowflake.go): prevent wg.Add race condition In VSCode, the staticcheck tool emits this warning: > should call wg.Add(1) before starting the goroutine to > avoid a race (SA2000)go-staticcheck To avoid this warning, just move wg.Add outside. --- client/snowflake.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/snowflake.go b/client/snowflake.go index bacc389..af9c2e4 100644 --- a/client/snowflake.go +++ b/client/snowflake.go @@ -56,8 +56,8 @@ func socksAcceptLoop(ln *pt.SocksListener, transport *sf.Transport, shutdown cha break } log.Printf("SOCKS accepted: %v", conn.Req) + wg.Add(1) go func() { - wg.Add(1) defer wg.Done() defer conn.Close()