Skip to content

Commit 43667d3

Browse files
ci: update golangci-lint to v2
update method: ``` golangci-lint migrate golangci-lint run --fix ``` and fix the last ones manually
1 parent 89e308c commit 43667d3

File tree

19 files changed

+66
-59
lines changed

19 files changed

+66
-59
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
with:
1515
go-version: "1.25.x"
1616
- name: golangci-lint
17-
uses: golangci/golangci-lint-action@v6
17+
uses: golangci/golangci-lint-action@v9
1818
with:
19-
version: v1.64.8
19+
version: v2.6.2
2020

2121
test:
2222
runs-on: ubuntu-latest

.golangci.yml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
run:
2-
# timeout for analysis, e.g. 30s, 5m, default is 1m
3-
timeout: 5m
1+
version: "2"
42
linters:
53
enable:
6-
#- golint
7-
#- interfacer
8-
- unconvert
9-
#- dupl
104
- goconst
11-
- gofmt
125
- misspell
13-
- unparam
146
- nakedret
157
- prealloc
168
- revive
17-
#- gosec
18-
linters-settings:
19-
misspell:
20-
locale: US
21-
revive:
9+
- unconvert
10+
- unparam
11+
settings:
12+
misspell:
13+
locale: US
14+
revive:
15+
rules:
16+
- name: redundant-build-tag
17+
exclusions:
18+
generated: lax
2219
rules:
23-
- name: redundant-build-tag
20+
- path: (.+)\.go$
21+
text: G104
22+
paths:
23+
- third_party$
24+
- builtin$
25+
- examples$
2426
issues:
25-
max-same-issues: 0
2627
max-issues-per-linter: 0
27-
exclude-use-default: false
28-
exclude:
29-
# gosec: Duplicated errcheck checks
30-
- G104
28+
max-same-issues: 0
29+
formatters:
30+
enable:
31+
- gofmt
32+
exclusions:
33+
generated: lax
34+
paths:
35+
- third_party$
36+
- builtin$
37+
- examples$

database/cassandra/cassandra.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func parseConsistency(consistencyStr string) (consistency gocql.Consistency, err
336336
var ok bool
337337
err, ok = r.(error)
338338
if !ok {
339-
err = fmt.Errorf("Failed to parse consistency \"%s\": %v", consistencyStr, r)
339+
err = fmt.Errorf("failed to parse consistency \"%s\": %v", consistencyStr, r)
340340
}
341341
}
342342
}()

database/clickhouse/clickhouse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,5 @@ func quoteIdentifier(name string) string {
307307
if end > -1 {
308308
name = name[:end]
309309
}
310-
return `"` + strings.Replace(name, `"`, `""`, -1) + `"`
310+
return `"` + strings.ReplaceAll(name, `"`, `""`) + `"`
311311
}

database/mysql/mysql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
ErrNilConfig = fmt.Errorf("no config")
3535
ErrNoDatabaseName = fmt.Errorf("no database name")
3636
ErrAppendPEM = fmt.Errorf("failed to append PEM")
37-
ErrTLSCertKeyConfig = fmt.Errorf("To use TLS client authentication, both x-tls-cert and x-tls-key must not be empty")
37+
ErrTLSCertKeyConfig = fmt.Errorf("to use TLS client authentication, both x-tls-cert and x-tls-key must not be empty")
3838
)
3939

4040
type Config struct {

database/pgx/pgx.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
181181
if s := purl.Query().Get("x-migrations-table-quoted"); len(s) > 0 {
182182
migrationsTableQuoted, err = strconv.ParseBool(s)
183183
if err != nil {
184-
return nil, fmt.Errorf("Unable to parse option x-migrations-table-quoted: %w", err)
184+
return nil, fmt.Errorf("unable to parse option x-migrations-table-quoted: %w", err)
185185
}
186186
}
187187
if (len(migrationsTable) > 0) && (migrationsTableQuoted) && ((migrationsTable[0] != '"') || (migrationsTable[len(migrationsTable)-1] != '"')) {
@@ -212,7 +212,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
212212
if s := purl.Query().Get("x-multi-statement"); len(s) > 0 {
213213
multiStatementEnabled, err = strconv.ParseBool(s)
214214
if err != nil {
215-
return nil, fmt.Errorf("Unable to parse option x-multi-statement: %w", err)
215+
return nil, fmt.Errorf("unable to parse option x-multi-statement: %w", err)
216216
}
217217
}
218218

@@ -412,7 +412,7 @@ func (p *Postgres) runStatement(statement []byte) error {
412412

413413
func computeLineFromPos(s string, pos int) (line uint, col uint, ok bool) {
414414
// replace crlf with lf
415-
s = strings.Replace(s, "\r\n", "\n", -1)
415+
s = strings.ReplaceAll(s, "\r\n", "\n")
416416
// pg docs: pos uses index 1 for the first character, and positions are measured in characters not bytes
417417
runes := []rune(s)
418418
if pos > len(runes) {
@@ -613,5 +613,5 @@ func quoteIdentifier(name string) string {
613613
if end > -1 {
614614
name = name[:end]
615615
}
616-
return `"` + strings.Replace(name, `"`, `""`, -1) + `"`
616+
return `"` + strings.ReplaceAll(name, `"`, `""`) + `"`
617617
}

database/pgx/pgx_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,10 @@ func Test_computeLineFromPos(t *testing.T) {
755755
t.Run(name, func(t *testing.T) {
756756
input := tc.input
757757
if crlf {
758-
input = strings.Replace(input, "\n", "\r\n", -1)
758+
input = strings.ReplaceAll(input, "\n", "\r\n")
759759
}
760760
if nonASCII {
761-
input = strings.Replace(input, "FROM", "FRÖM", -1)
761+
input = strings.ReplaceAll(input, "FROM", "FRÖM")
762762
}
763763
gotLine, gotCol, gotOK := computeLineFromPos(input, tc.pos)
764764

database/pgx/v5/pgx.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
157157
if s := purl.Query().Get("x-migrations-table-quoted"); len(s) > 0 {
158158
migrationsTableQuoted, err = strconv.ParseBool(s)
159159
if err != nil {
160-
return nil, fmt.Errorf("Unable to parse option x-migrations-table-quoted: %w", err)
160+
return nil, fmt.Errorf("unable to parse option x-migrations-table-quoted: %w", err)
161161
}
162162
}
163163
if (len(migrationsTable) > 0) && (migrationsTableQuoted) && ((migrationsTable[0] != '"') || (migrationsTable[len(migrationsTable)-1] != '"')) {
@@ -188,7 +188,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
188188
if s := purl.Query().Get("x-multi-statement"); len(s) > 0 {
189189
multiStatementEnabled, err = strconv.ParseBool(s)
190190
if err != nil {
191-
return nil, fmt.Errorf("Unable to parse option x-multi-statement: %w", err)
191+
return nil, fmt.Errorf("unable to parse option x-multi-statement: %w", err)
192192
}
193193
}
194194

@@ -303,7 +303,7 @@ func (p *Postgres) runStatement(statement []byte) error {
303303

304304
func computeLineFromPos(s string, pos int) (line uint, col uint, ok bool) {
305305
// replace crlf with lf
306-
s = strings.Replace(s, "\r\n", "\n", -1)
306+
s = strings.ReplaceAll(s, "\r\n", "\n")
307307
// pg docs: pos uses index 1 for the first character, and positions are measured in characters not bytes
308308
runes := []rune(s)
309309
if pos > len(runes) {
@@ -476,5 +476,5 @@ func quoteIdentifier(name string) string {
476476
if end > -1 {
477477
name = name[:end]
478478
}
479-
return `"` + strings.Replace(name, `"`, `""`, -1) + `"`
479+
return `"` + strings.ReplaceAll(name, `"`, `""`) + `"`
480480
}

database/pgx/v5/pgx_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,10 @@ func Test_computeLineFromPos(t *testing.T) {
730730
t.Run(name, func(t *testing.T) {
731731
input := tc.input
732732
if crlf {
733-
input = strings.Replace(input, "\n", "\r\n", -1)
733+
input = strings.ReplaceAll(input, "\n", "\r\n")
734734
}
735735
if nonASCII {
736-
input = strings.Replace(input, "FROM", "FRÖM", -1)
736+
input = strings.ReplaceAll(input, "FROM", "FRÖM")
737737
}
738738
gotLine, gotCol, gotOK := computeLineFromPos(input, tc.pos)
739739

database/postgres/postgres.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
165165
if s := purl.Query().Get("x-migrations-table-quoted"); len(s) > 0 {
166166
migrationsTableQuoted, err = strconv.ParseBool(s)
167167
if err != nil {
168-
return nil, fmt.Errorf("Unable to parse option x-migrations-table-quoted: %w", err)
168+
return nil, fmt.Errorf("unable to parse option x-migrations-table-quoted: %w", err)
169169
}
170170
}
171171
if (len(migrationsTable) > 0) && (migrationsTableQuoted) && ((migrationsTable[0] != '"') || (migrationsTable[len(migrationsTable)-1] != '"')) {
@@ -196,7 +196,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
196196
if s := purl.Query().Get("x-multi-statement"); len(s) > 0 {
197197
multiStatementEnabled, err = strconv.ParseBool(s)
198198
if err != nil {
199-
return nil, fmt.Errorf("Unable to parse option x-multi-statement: %w", err)
199+
return nil, fmt.Errorf("unable to parse option x-multi-statement: %w", err)
200200
}
201201
}
202202

@@ -319,7 +319,7 @@ func (p *Postgres) runStatement(statement []byte) error {
319319

320320
func computeLineFromPos(s string, pos int) (line uint, col uint, ok bool) {
321321
// replace crlf with lf
322-
s = strings.Replace(s, "\r\n", "\n", -1)
322+
s = strings.ReplaceAll(s, "\r\n", "\n")
323323
// pg docs: pos uses index 1 for the first character, and positions are measured in characters not bytes
324324
runes := []rune(s)
325325
if pos > len(runes) {

0 commit comments

Comments
 (0)