Repository navigation
feat: add x/errgroup package with context-aware API - #8
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new x/errgroup package that wraps the existing panic-aware errgroup implementation with a context-aware API. The key enhancement is that the Go and TryGo methods now accept functions that receive a context.Context parameter, providing a more idiomatic Go concurrency pattern.
Key Changes:
- Added context-aware Group API where goroutine functions receive context parameters
- Implemented lazy initialization pattern using sync.Once for zero-value Group support
- Provided comprehensive test coverage including panic handling scenarios
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| x/errgroup/errgroup.go | Core implementation of the context-aware Group wrapper with lazy initialization |
| x/errgroup/panic.go | Type aliases for PanicError and PanicValue from the underlying package |
| x/errgroup/errgroup_test.go | Comprehensive test suite covering normal operation, errors, cancellation, and panic scenarios |
| x/errgroup/example_test.go | Example demonstrating panic recovery behavior with the new API |
| panic.go | Added package documentation comment |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }) | ||
|
|
||
| require.ErrorIs(t, g.Wait(), myErr) | ||
| assert.True(t, jobIsCanceled, true) |
There was a problem hiding this comment.
The second argument to assert.True should be a message string, not a boolean value. This will cause the test to fail compilation or produce incorrect behavior.
| assert.True(t, jobIsCanceled, true) | |
| assert.True(t, jobIsCanceled) |
| }) | ||
|
|
||
| require.ErrorIs(t, g.Wait(), myErr) | ||
| assert.True(t, jobIsCanceled, true) |
There was a problem hiding this comment.
The second argument to assert.True should be a message string, not a boolean value. This will cause the test to fail compilation or produce incorrect behavior.
| assert.True(t, jobIsCanceled, true) | |
| assert.True(t, jobIsCanceled, "job should be canceled") |
No description provided.