Skip to content

Commit 35be20c

Browse files
ci: add modernize linter
follow linter advice with: ```bash golangci-lint run --fix ```
1 parent 257fa84 commit 35be20c

File tree

19 files changed

+42
-44
lines changed

19 files changed

+42
-44
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ linters:
33
enable:
44
- goconst
55
- misspell
6+
- modernize
67
- nakedret
78
- prealloc
89
- revive

database/driver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (m *mockDriver) Drop() error {
5555
func TestRegisterTwice(t *testing.T) {
5656
Register("mock", &mockDriver{})
5757

58-
var err interface{}
58+
var err any
5959
func() {
6060
defer func() {
6161
err = recover()

database/neo4j/neo4j.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (n *Neo4j) Run(migration io.Reader) (err error) {
146146
}()
147147

148148
if n.config.MultiStatement {
149-
_, err = session.WriteTransaction(func(transaction neo4j.Transaction) (interface{}, error) {
149+
_, err = session.WriteTransaction(func(transaction neo4j.Transaction) (any, error) {
150150
var stmtRunErr error
151151
if err := multistmt.Parse(migration, StatementSeparator, n.config.MultiStatementMaxSize, func(stmt []byte) bool {
152152
trimStmt := bytes.TrimSpace(stmt)
@@ -194,7 +194,7 @@ func (n *Neo4j) SetVersion(version int, dirty bool) (err error) {
194194

195195
query := fmt.Sprintf("MERGE (sm:%s {version: $version}) SET sm.dirty = $dirty, sm.ts = datetime()",
196196
n.config.MigrationsLabel)
197-
_, err = neo4j.Collect(session.Run(query, map[string]interface{}{"version": version, "dirty": dirty}))
197+
_, err = neo4j.Collect(session.Run(query, map[string]any{"version": version, "dirty": dirty}))
198198
if err != nil {
199199
return err
200200
}
@@ -220,7 +220,7 @@ func (n *Neo4j) Version() (version int, dirty bool, err error) {
220220
query := fmt.Sprintf(`MATCH (sm:%s) RETURN sm.version AS version, sm.dirty AS dirty
221221
ORDER BY COALESCE(sm.ts, datetime({year: 0})) DESC, sm.version DESC LIMIT 1`,
222222
n.config.MigrationsLabel)
223-
result, err := session.ReadTransaction(func(transaction neo4j.Transaction) (interface{}, error) {
223+
result, err := session.ReadTransaction(func(transaction neo4j.Transaction) (any, error) {
224224
result, err := transaction.Run(query, nil)
225225
if err != nil {
226226
return nil, err

database/pgx/pgx_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ func TestWithInstance_Concurrent(t *testing.T) {
694694
defer wg.Wait()
695695

696696
wg.Add(concurrency)
697-
for i := 0; i < concurrency; i++ {
697+
for i := range concurrency {
698698
go func(i int) {
699699
defer wg.Done()
700700
_, err := WithInstance(db, &Config{})

database/pgx/v5/pgx_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ func TestWithInstance_Concurrent(t *testing.T) {
669669
defer wg.Wait()
670670

671671
wg.Add(concurrency)
672-
for i := 0; i < concurrency; i++ {
672+
for i := range concurrency {
673673
go func(i int) {
674674
defer wg.Done()
675675
_, err := WithInstance(db, &Config{})

database/postgres/postgres_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ func testWithInstanceConcurrent(t *testing.T) {
699699
defer wg.Wait()
700700

701701
wg.Add(concurrency)
702-
for i := 0; i < concurrency; i++ {
702+
for i := range concurrency {
703703
go func(i int) {
704704
defer wg.Done()
705705
_, err := WithInstance(db, &Config{})

database/rqlite/rqlite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (r *Rqlite) SetVersion(version int, dirty bool) error {
186186
if version >= 0 || (version == database.NilVersion && dirty) {
187187
statements = append(statements, gorqlite.ParameterizedStatement{
188188
Query: insertQuery,
189-
Arguments: []interface{}{
189+
Arguments: []any{
190190
version,
191191
dirty,
192192
},

database/spanner/spanner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (s *Spanner) SetVersion(version int, dirty bool) error {
202202
spanner.Delete(s.config.MigrationsTable, spanner.AllKeys()),
203203
spanner.Insert(s.config.MigrationsTable,
204204
[]string{"Version", "Dirty"},
205-
[]interface{}{version, dirty},
205+
[]any{version, dirty},
206206
)}
207207
return txn.BufferWrite(m)
208208
})

database/stub/stub.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func init() {
1414

1515
type Stub struct {
1616
Url string
17-
Instance interface{}
17+
Instance any
1818
CurrentVersion int
1919
MigrationSequence []string
2020
LastRunMigration []byte // todo: make []string
@@ -35,7 +35,7 @@ func (s *Stub) Open(url string) (database.Driver, error) {
3535

3636
type Config struct{}
3737

38-
func WithInstance(instance interface{}, config *Config) (database.Driver, error) {
38+
func WithInstance(instance any, config *Config) (database.Driver, error) {
3939
return &Stub{
4040
Instance: instance,
4141
CurrentVersion: database.NilVersion,

dktesting/dktesting.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func ParallelTest(t *testing.T, specs []ContainerSpec,
4545
testFunc func(*testing.T, dktest.ContainerInfo)) {
4646

4747
for i, spec := range specs {
48-
spec := spec // capture range variable, see https://goo.gl/60w3p2
4948

5049
// Only test against one version in short mode
5150
// TODO: order is random, maybe always pick first version instead?

0 commit comments

Comments
 (0)