-
Notifications
You must be signed in to change notification settings - Fork 5k
refactor: simplify some implementations by modern go features #21998
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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21998 +/- ##
===========================================
+ Coverage 45.36% 65.87% +20.50%
===========================================
Files 244 1071 +827
Lines 13333 115703 +102370
Branches 2719 2925 +206
===========================================
+ Hits 6049 76215 +70166
- Misses 6983 35264 +28281
- Partials 301 4224 +3923
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
wy65701436
left a comment
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.
lgtm
|
@stonezdj Please help to review this change, thanks. |
Signed-off-by: chlins <[email protected]>
…or#21998) Signed-off-by: chlins <[email protected]>
This pull request introduces several changes aimed at improving code readability, simplifying logic, and leveraging Go's standard library for better performance and maintainability. The most significant updates include replacing manual loops with
rangesyntax or utility functions likeslices.Containsandmaps.Copy, as well as removing unused code. Below is a categorized summary of the most important changes:Refactoring Loops for Simplification
forloops withrangesyntax in multiple functions to simplify iteration logic. Examples includeTestMaxOpenConnsinpgsql_test.go,ArrayEqualintestutils.go, andGenerateRandomStringWithLeninutils.go. [1] [2] [3]Leveraging Standard Library Functions
slices.Containsin functions likeskippedUnusedJobTypeinmonitor.goandhasCapabilityinchecker.go. [1] [2]maps.Copyto simplify map copying in functions likeDecodeincodec.goandBuildincontext.go. [1] [2]Code Cleanup
StringInSlicefromutils.goto reduce clutter and improve maintainability.Bug Fixes and Logic Adjustments
copyBlobByChunkintransfer.goto use a single expression for calculating the end range, improving clarity and reducing potential off-by-one errors.Dependency Updates
slicesandmapspackages in various files to enable the use of utility functions for slices and maps. [1] [2] [3]These changes collectively enhance the codebase by improving readability, reducing redundancy, and leveraging modern Go practices.Thank you for contributing to Harbor!
Comprehensive Summary of your change
Issue being fixed
Fixes #(issue)
Please indicate you've done the following: