ci: add modernize linter#1342
Open
PascalBourdier wants to merge 1 commit intogolang-migrate:masterfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds the modernize linter to the golangci-lint configuration and applies its recommendations throughout the codebase. The modernize linter suggests using modern Go idioms that are available in Go 1.22+ (the project uses Go 1.24.0).
Key changes:
- Enabled the
modernizelinter in.golangci.yml - Replaced
interface{}withanyalias throughout the codebase for better readability - Removed unnecessary range variable captures (automatic in Go 1.22+)
- Replaced
sort.Slicewith more efficientslices.Sort - Updated benchmark loops to use
b.Loop()method - Simplified loop syntax using
for i := range npattern
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.golangci.yml |
Added modernize linter to the enabled linters list |
testing/testing.go |
Removed unnecessary range variable capture comment and code |
dktesting/dktesting.go |
Removed unnecessary range variable capture comment and code |
source/stub/stub.go |
Replaced interface{} with any in struct field and function parameter |
source/migration.go |
Replaced sort.Slice with slices.Sort and added slices import |
source/go_bindata/go-bindata.go |
Replaced interface{} with any in function parameter |
source/file/file_test.go |
Simplified loop syntax to for i := range 1000, replaced benchmark loops with b.Loop() |
migrate.go |
Replaced interface{} with any in channel types and function parameters |
migrate_test.go |
Replaced interface{} with any in channel type and simplified loop syntax |
log.go |
Replaced interface{} with any in Logger interface method signature |
internal/cli/log.go |
Replaced interface{} with any in Log method signatures |
database/stub/stub.go |
Replaced interface{} with any in struct field and function parameter |
database/spanner/spanner.go |
Replaced interface{} with any in slice literal |
database/rqlite/rqlite.go |
Replaced interface{} with any in slice literal |
database/postgres/postgres_test.go |
Simplified loop syntax to for i := range concurrency |
database/pgx/v5/pgx_test.go |
Simplified loop syntax to for i := range concurrency |
database/pgx/pgx_test.go |
Simplified loop syntax to for i := range concurrency |
database/neo4j/neo4j.go |
Replaced interface{} with any in function signatures and map types |
database/driver_test.go |
Replaced interface{} with any in variable declaration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
follow linter advice with: ```bash golangci-lint run --fix ```
35be20c to
70106c0
Compare
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.
follow linter advice with: