go fix, and modernize some code - #73
Merged
Merged
Conversation
automated fixes from; `go fix -mod=readonly -all ./...` Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Also move the backoff var closer to where used Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Remove closed sinks directly by index while iterating over the broadcaster's sink slice. This avoids searching the slice again for every closed sink and prevents skipping entries when removing elements during iteration. Use slices.Index and slices.Delete for explicit sink removals, replacing the local remove helper and manual slice manipulation. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
There was a problem hiding this comment.
Pull request overview
This PR applies go fix-driven modernization across the events package, updating APIs and idioms (notably math/rand/v2, sync/atomic typed atomics, and slices helpers) and refining broadcaster behavior to remove closed sinks safely during iteration.
Changes:
- Modernize Go code and types (e.g.,
any, typed atomics,min, integerrangeloops) and update randomness usage tomath/rand/v2. - Refactor
Broadcaster.runto delete closed sinks in-place during iteration, and useslices.Contains/Index/Deletefor clearer sink management. - Simplify
String()implementations and adjust structured logging usage to avoid mutating logrus entries via chainedWithFieldcalls.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| retry.go | Switch to math/rand/v2, use typed atomic.Uint64, avoid logger shadowing, and minor cleanup/modernization. |
| retry_test.go | Modernize loops and simplify expected backoff calculation with min(). |
| queue.go | Add clarifying comment about Front() non-nil under the lock. |
| filter_test.go | Modernize integer loop to for i := range nevents. |
| event.go | Replace interface{} with any for Event. |
| common_test.go | Switch to math/rand/v2 and modernize variadic arg types to ...any. |
| channel.go | Simplify String() by directly sprinting a map[string]any. |
| broadcast.go | Use slices helpers; fix sink removal during iteration; adjust logrus field usage; simplify String(). |
| broadcast_test.go | Modernize integer loops in tests/benchmarks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
vvoland
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
go fix, and modernize some code
automated fixes from;
go fix -mod=readonly -all ./...rename/remove intermediate vars that shadowed
Also move the backoff var closer to where used
switch to math/rand/v2
avoid chainging logrus.WithField
refactor: avoid redundant sink lookup when broadcasting
Remove closed sinks directly by index while iterating over the broadcaster's
sink slice. This avoids searching the slice again for every closed sink and
prevents skipping entries when removing elements during iteration.
Use slices.Index and slices.Delete for explicit sink removals, replacing the
local remove helper and manual slice manipulation.