errgroup: use consistent read for SetLimit panic

This could produce a confusing panic message if the second len(g.sem)
call returns 0. Avoid that by reading it once.

Change-Id: Ibdb4963f90921bc20427b3f1e2de410638f6cb6b
Reviewed-on: https://go-review.googlesource.com/c/sync/+/726280
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
1 file changed
tree: 4981880b813298cbba7e0a264c5893e333df058a
  1. errgroup/
  2. semaphore/
  3. singleflight/
  4. syncmap/
  5. codereview.cfg
  6. CONTRIBUTING.md
  7. go.mod
  8. LICENSE
  9. PATENTS
  10. README.md
README.md

Go Sync

Go Reference

This repository provides Go concurrency primitives in addition to the ones provided by the language and “sync” and “sync/atomic” packages.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.

The git repository is https://go.googlesource.com/sync.

The main issue tracker for the sync repository is located at https://go.dev/issues. Prefix your issue with “x/sync:” in the subject line, so it is easy to find.