sync/errgroup: improve documentation for semaphore limit behavior
Updated the documentation for `SetLimit` and `Go` functions in the
`errgroup` package. the note clarifies the behavior when the semaphore
limit is set to zero, which could lead to a deadlock if not handled
properly. the updated documentation warns users to set a positive
semaphore limit to avoid blocking goroutines and potential deadlock
this change improves the clarity of API and helps users understand how
to properly use the semaphore limit to prevent issues in concurrent
execution
Change-Id: Ie62acc38ef804b3590c04bddba00a3cce21e8cef
Reviewed-on: https://go-review.googlesource.com/c/sync/+/642215
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
diff --git a/errgroup/errgroup.go b/errgroup/errgroup.go
index 948a3ee..b832259 100644
--- a/errgroup/errgroup.go
+++ b/errgroup/errgroup.go
@@ -118,6 +118,7 @@
// SetLimit limits the number of active goroutines in this group to at most n.
// A negative value indicates no limit.
+// A limit of zero will prevent any new goroutines from being added.
//
// Any subsequent call to the Go method will block until it can add an active
// goroutine without exceeding the configured limit.