-
Notifications
You must be signed in to change notification settings - Fork 594
refactor(general): modernize #4903
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
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 modernizes Go code by adopting newer standard library APIs introduced in recent Go versions. The changes follow recommendations from the golang.org/x/tools/gopls/internal/analysis/modernize tool.
Key changes:
- Replaced
strings.Split()iteration patterns withstrings.SplitSeq()for more efficient sequential processing - Replaced manual map copying loops with
maps.Copy()for clearer intent and better performance - Replaced
strings.HasPrefix() + strings.TrimPrefix()patterns withstrings.CutPrefix()for atomic prefix handling - Replaced
sort.Slice()calls withslices.Sort()for simpler, more idiomatic sorting
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/gettool/gettool.go | Replaced strings.Split iteration with strings.SplitSeq |
| tests/tools/kopiarunner/kopia_snapshotter.go | Replaced multiple strings.Split iterations with strings.SplitSeq and strings.FieldsSeq |
| tests/tools/fio/options.go | Replaced manual map copy loops with maps.Copy |
| tests/robustness/fiofilewriter/fio_filewriter.go | Replaced manual map copy loops with maps.Copy |
| tests/end_to_end_test/snapshot_fail_test.go | Replaced manual map copy loops with maps.Copy |
| tests/end_to_end_test/repository_connect_test.go | Replaced strings.HasPrefix + TrimPrefix with strings.CutPrefix |
| tests/end_to_end_test/auto_update_test.go | Replaced manual map copy loop with maps.Copy |
| snapshot/manager.go | Replaced manual map copy loop with maps.Copy |
| repo/manifest/manifest_manager_test.go | Replaced sort.Slice with slices.Sort |
| repo/compression/compressor_test.go | Replaced sort.Slice with slices.Sort |
| repo/blob/webdav/webdav_storage_test.go | Replaced manual map copy loop with maps.Copy |
| notification/sender/webhook/webhook_sender.go | Replaced strings.Split iteration with strings.SplitSeq |
| internal/uitask/uitask_counter.go | Replaced manual map copy loop with maps.Copy |
| internal/testutil/tmpdir.go | Replaced strings.Split iteration with strings.SplitSeq |
| internal/testutil/serverparameters.go | Replaced multiple strings.HasPrefix + TrimPrefix patterns with strings.CutPrefix |
| internal/server/server_mount_manager.go | Replaced manual map copy loop with maps.Copy |
| internal/server/server.go | Replaced manual map copy loops with maps.Copy |
| internal/releasable/releaseable_tracker.go | Replaced manual map copy loop with maps.Copy |
| internal/cache/content_cache_test.go | Replaced sort.Slice with slices.Sort, removed unused sort import |
| internal/blobtesting/object_locking_map.go | Replaced sort.Slice with slices.Sort |
| internal/blobtesting/map.go | Replaced sort.Slice with slices.Sort |
| internal/blobtesting/asserts.go | Replaced sort.Slice with slices.Sort |
| fs/cachefs/cache_test.go | Replaced manual map copy loop with maps.Copy |
| cli/command_server_tls.go | Replaced strings.HasPrefix + TrimPrefix with strings.CutPrefix |
| cli/command_policy_set_scheduling.go | Replaced strings.Split iterations with strings.SplitSeq |
| cli/command_blob_shards_modify.go | Replaced strings.Split iteration with strings.SplitSeq |
| cli/command_benchmark_compression.go | Replaced strings.Split iteration with strings.SplitSeq |
| cli/command_acl_add.go | Replaced strings.Split iteration with strings.SplitSeq |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| fields := strings.FieldsSeq(l) | ||
|
|
||
| for _, f := range fields { | ||
| for f := range fields { |
Copilot
AI
Oct 23, 2025
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.
This code attempts to range over the result of strings.FieldsSeq, which does not exist. Even if it did exist and returned an iterator, the iteration would need to be updated to match the iterator protocol. Since strings.Fields returns []string, this should be for _, f := range fields.
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.
@copilot this is incorrect
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4903 +/- ##
==========================================
+ Coverage 75.86% 77.96% +2.09%
==========================================
Files 470 537 +67
Lines 37301 31216 -6085
==========================================
- Hits 28299 24336 -3963
+ Misses 7071 4837 -2234
- Partials 1931 2043 +112 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Applies the modernize changes for the following categories:
Refs: