From 396f3a06ea2a49eb410f12e244c0dd77095d0de9 Mon Sep 17 00:00:00 2001 From: Sean Liao Date: Fri, 21 Mar 2025 19:51:13 +0000 Subject: [PATCH] errgroup: document calling Go before Wait Fixes golang/go#70284 Change-Id: I31d60ea182226c032b0ffbddcbb5b53675dfd5e6 Reviewed-on: https://go-review.googlesource.com/c/sync/+/660075 LUCI-TryBot-Result: Go LUCI Reviewed-by: Alan Donovan Auto-Submit: Damien Neil Reviewed-by: Damien Neil --- errgroup/errgroup.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/errgroup/errgroup.go b/errgroup/errgroup.go index a4ea5d1..f8c3c09 100644 --- a/errgroup/errgroup.go +++ b/errgroup/errgroup.go @@ -18,7 +18,7 @@ import ( type token struct{} // A Group is a collection of goroutines working on subtasks that are part of -// the same overall task. +// the same overall task. A Group should not be reused for different tasks. // // A zero Group is valid, has no limit on the number of active goroutines, // and does not cancel on error. @@ -61,6 +61,7 @@ func (g *Group) Wait() error { } // Go calls the given function in a new goroutine. +// The first call to Go must happen before a Wait. // It blocks until the new goroutine can be added without the number of // active goroutines in the group exceeding the configured limit. //