Skip to content

Commit 53977a0

Browse files
committed
chore(deps): update golangci-lint version to support go1.25
1 parent 4a1cc71 commit 53977a0

File tree

15 files changed

+239
-81
lines changed

15 files changed

+239
-81
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ runs:
7878
if: ${{ inputs.language == 'go' }}
7979
shell: bash
8080
run: |
81-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.3
81+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.4.0
8282
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
8383
go install golang.org/x/tools/cmd/[email protected]
8484
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
linters-settings:
2+
govet:
3+
enable-all: true
4+
disable:
5+
- fieldalignment
6+
7+
revive:
8+
rules:
9+
- name: var-naming
10+
disabled: true
11+
12+
linters:
13+
enable-all: true
14+
15+
disable:
16+
- godox
17+
- bodyclose
18+
- contextcheck
19+
- interfacebloat
20+
- gci
21+
- gosmopolitan
22+
- wsl
23+
- varnamelen
24+
- nlreturn
25+
- err113
26+
- gochecknoglobals
27+
- exhaustruct
28+
- exhaustive
29+
- depguard
30+
- lll
31+
- forbidigo
32+
- gochecknoinits
33+
- cyclop
34+
- errorlint
35+
- gomnd
36+
- tagliatelle
37+
- nilnil
38+
- stylecheck
39+
- musttag
40+
- errchkjson
41+
- nonamedreturns
42+
- inamedparam
43+
- ineffassign
44+
- dupword
45+
- nestif
46+
- goconst
47+
- funlen
48+
- dupl
49+
- unparam
50+
- gocognit
51+
- forcetypeassert
52+
- wastedassign
53+
- gocyclo
54+
- maintidx
55+
- copyloopvar
56+
- intrange
57+
- canonicalheader
58+
- mnd
59+
- perfsprint
60+
- containedctx
61+
62+
# Deprecated
63+
- execinquery
64+
- exportloopref
65+
66+
issues:
67+
exclude-generated: disable
68+
69+
run:
70+
concurrency: 2
71+
timeout: 10m
Lines changed: 71 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,84 @@
1-
linters-settings:
2-
govet:
3-
enable-all: true
4-
disable:
5-
- fieldalignment
6-
7-
revive:
8-
rules:
9-
- name: var-naming
10-
disabled: true
11-
1+
version: "2"
2+
run:
3+
concurrency: 2
124
linters:
13-
enable-all: true
14-
5+
default: all
156
disable:
16-
- godox
177
- bodyclose
8+
- canonicalheader
9+
- containedctx
1810
- contextcheck
19-
- interfacebloat
20-
- gci
21-
- gosmopolitan
22-
- wsl
23-
- varnamelen
24-
- nlreturn
11+
- copyloopvar
12+
- cyclop
13+
- depguard
14+
- dupl
15+
- dupword
2516
- err113
26-
- gochecknoglobals
27-
- exhaustruct
17+
- errchkjson
18+
- errorlint
2819
- exhaustive
29-
- depguard
30-
- lll
20+
- exhaustruct
3121
- forbidigo
32-
- gochecknoinits
33-
- cyclop
34-
- errorlint
35-
- gomnd
36-
- tagliatelle
37-
- nilnil
38-
- stylecheck
39-
- musttag
40-
- errchkjson
41-
- nonamedreturns
42-
- inamedparam
43-
- ineffassign
44-
- dupword
45-
- nestif
46-
- goconst
22+
- forcetypeassert
23+
- funcorder
4724
- funlen
48-
- dupl
49-
- unparam
25+
- gochecknoglobals
26+
- gochecknoinits
5027
- gocognit
51-
- forcetypeassert
52-
- wastedassign
28+
- goconst
5329
- gocyclo
54-
- maintidx
55-
- copyloopvar
30+
- godox
31+
- gosmopolitan
32+
- inamedparam
33+
- ineffassign
34+
- interfacebloat
5635
- intrange
57-
- canonicalheader
36+
- lll
37+
- maintidx
5838
- mnd
39+
- musttag
40+
- nestif
41+
- nilnil
42+
- nlreturn
43+
- noctx
44+
- noinlineerr
45+
- nonamedreturns
5946
- perfsprint
60-
- containedctx
61-
62-
# Deprecated
63-
- execinquery
64-
- exportloopref
65-
66-
issues:
67-
exclude-generated: disable
68-
69-
run:
70-
concurrency: 2
71-
timeout: 10m
47+
- recvcheck
48+
- staticcheck
49+
- tagliatelle
50+
- unparam
51+
- varnamelen
52+
- wastedassign
53+
- wsl
54+
settings:
55+
govet:
56+
disable:
57+
- fieldalignment
58+
enable-all: true
59+
revive:
60+
rules:
61+
- name: var-naming
62+
disabled: true
63+
exclusions:
64+
generated: disable
65+
presets:
66+
- comments
67+
- common-false-positives
68+
- legacy
69+
- std-error-handling
70+
paths:
71+
- third_party$
72+
- builtin$
73+
- examples$
74+
formatters:
75+
enable:
76+
- gofmt
77+
- gofumpt
78+
- goimports
79+
exclusions:
80+
generated: disable
81+
paths:
82+
- third_party$
83+
- builtin$
84+
- examples$

clients/algoliasearch-client-go/algolia/debug/debug.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ func Display(input any) {
3030
if !debug {
3131
return
3232
}
33+
3334
start := time.Now()
35+
3436
var msg string
37+
3538
switch v := input.(type) {
3639
case *http.Request:
3740
msg = debugRequest(v)
@@ -40,6 +43,7 @@ func Display(input any) {
4043
default:
4144
msg = fmt.Sprintf("do not know how to display %#v", v)
4245
}
46+
4347
Println(msg)
4448
fmt.Printf("took %s\n", time.Since(start))
4549
}
@@ -52,6 +56,7 @@ func Printf(format string, a ...any) {
5256
if !debug {
5357
return
5458
}
59+
5560
msg := fmt.Sprintf(format, a...)
5661
fmt.Printf("> ALGOLIA DEBUG: %s", msg)
5762
}

clients/algoliasearch-client-go/algolia/debug/utils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ func copyReadCloser(r io.ReadCloser) (io.ReadCloser, string) {
1616
if r == nil {
1717
return nil, ""
1818
}
19+
1920
data, err := io.ReadAll(r)
2021
_ = r.Close()
22+
2123
if err != nil {
2224
return nil, ""
2325
}
26+
2427
return io.NopCloser(bytes.NewReader(data)), string(data)
2528
}
2629

@@ -29,10 +32,12 @@ func decodeGzipContent(in string) (string, error) {
2932
if err != nil {
3033
return in, fmt.Errorf("cannot open content with gzip.Reader: %w", err)
3134
}
35+
3236
out, err := io.ReadAll(gr)
3337
if err != nil {
3438
return in, fmt.Errorf("cannot read content from gzip.Reader: %w", err)
3539
}
40+
3641
return string(out), nil
3742
}
3843

@@ -58,10 +63,12 @@ func extractBody(body io.ReadCloser, c compression.Compression) (io.ReadCloser,
5863

5964
func prettyPrintJSON(input string) string {
6065
var b bytes.Buffer
66+
6167
err := json.Indent(&b, []byte(input), "\t", " ")
6268
if err != nil {
6369
return input
6470
}
71+
6572
return strings.TrimSuffix(b.String(), "\n")
6673
}
6774

@@ -88,8 +95,10 @@ func debugRequest(req *http.Request) string {
8895
if strings.Contains(strings.ToLower(k), "algolia") {
8996
str = strings.Repeat("*", len(str))
9097
}
98+
9199
msg += fmt.Sprintf("\theader=%s:%q\n", k, str)
92100
}
101+
93102
msg += fmt.Sprintf("\tbody=\n\t%s\n", prettyPrintJSON(body))
94103

95104
return msg
@@ -101,6 +110,7 @@ func debugResponse(res *http.Response) string {
101110
}
102111

103112
var body string
113+
104114
res.Body, body = extractBody(res.Body, compression.NONE)
105115

106116
msg := "> ALGOLIA DEBUG response:\n"

clients/algoliasearch-client-go/algolia/errs/no_more_host_to_try_err.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func (e *NoMoreHostToTryError) Error() string {
2525
if len(e.intermediateNetworkErrors) > 0 {
2626
return fmt.Errorf("all hosts have been contacted unsuccessfully, it can either be a server or a network error or wrong appID/key credentials were used. %w", errors.Join(e.intermediateNetworkErrors...)).Error()
2727
}
28+
2829
return "all hosts have been contacted unsuccessfully, it can either be a server or a network error or wrong appID/key credentials were used. You can use 'ExposeIntermediateNetworkErrors: true' in the config to investigate."
2930
}
3031

clients/algoliasearch-client-go/algolia/transport/retry_strategy.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Host struct {
2929

3030
type RetryStrategy struct {
3131
sync.RWMutex
32+
3233
hosts []StatefulHost
3334
writeTimeout time.Duration
3435
readTimeout time.Duration
@@ -107,7 +108,7 @@ func (s *RetryStrategy) Decide(h Host, code int, err error) Outcome {
107108
return Retry
108109
}
109110

110-
if !(isZero(code) || is4xx(code) || is2xx(code)) || isNetworkError(err) {
111+
if (!isZero(code) && !is4xx(code) && !is2xx(code)) || isNetworkError(err) {
111112
s.markDown(h)
112113
return Retry
113114
}
@@ -146,6 +147,7 @@ func isNetworkError(err error) bool {
146147
if err == nil {
147148
return false
148149
}
150+
149151
_, ok := err.(net.Error)
150152
// We need to ensure that the error is a net.Error but not a
151153
// context.DeadlineExceeded error (which is actually a net.Error), because
@@ -157,6 +159,7 @@ func isTimeoutError(err error) bool {
157159
if err == nil {
158160
return false
159161
}
162+
160163
return strings.Contains(err.Error(), context.DeadlineExceeded.Error())
161164
}
162165

0 commit comments

Comments
 (0)