From 94d5157bf216041100d4384cc2361db327b8a7e5 Mon Sep 17 00:00:00 2001 From: sauran Date: Wed, 1 Oct 2025 04:22:44 +0500 Subject: [PATCH] Update WaitGroup usage instructions for Go 1.25 to include new Go method syntax --- instructions/go.instructions.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/instructions/go.instructions.md b/instructions/go.instructions.md index 60506c1..738c191 100644 --- a/instructions/go.instructions.md +++ b/instructions/go.instructions.md @@ -174,7 +174,13 @@ Follow idiomatic Go practices and community standards when writing Go code. Thes - Choose between channels and mutexes based on the use case: use channels for communication, mutexes for protecting state - Use `sync.Once` for one-time initialization - WaitGroup usage by Go version: - - If `go >= 1.25` in `go.mod`, use the new `WaitGroup` pattern + - If `go >= 1.25` in `go.mod`, use the new `WaitGroup.Go` method ([documentation](https://pkg.go.dev/sync#WaitGroup)): + ```go + var wg sync.WaitGroup + wg.Go(task1) + wg.Go(task2) + wg.Wait() + ``` - If `go < 1.25`, use the classic `Add`/`Done` pattern ## Error Handling Patterns