-
Notifications
You must be signed in to change notification settings - Fork 524
refactor: use slices.Contains to simplify code #6357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: clonemycode <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6357 +/- ##
==========================================
- Coverage 50.63% 50.46% -0.17%
==========================================
Files 653 653
Lines 110343 110342 -1
==========================================
- Hits 55872 55685 -187
- Misses 51601 51796 +195
+ Partials 2870 2861 -9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors membership checks to use the new slices.Contains function from Go 1.21, making the code more concise and readable.
- Replace manual
forloops inphonebook_test.gowithslices.Contains - Simplify the
Setmethod incmd/util/cmd.goby usingslices.Contains - Add
slicesto the import blocks where needed
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| network/phonebook/phonebook_test.go | Replaced nested loops with slices.Contains in tests |
| cmd/util/cmd.go | Simplified allowed-value check in CobraStringValue.Set() |
Comments suppressed due to low confidence (1)
go.mod:1
- Since the code now imports the standard-library
slicespackage (added in Go 1.21), please update thegodirective ingo.modto1.21to ensure compatibility.
module github.com/algorand/go-algorand
|
Thanks for the approved. |
Summary
There is a new function added in the go1.21 standard library, which can make the code more concise and easy to read.
Test Plan