Skip to content

Commit e7a988b

Browse files
committed
Pin golangci-lint to v1.43.0 and fix issues
1 parent 62a20c7 commit e7a988b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+213
-228
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: golangci/golangci-lint-action@v2
3434
with:
3535
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
36-
version: 'latest'
36+
version: 'v1.43.0'
3737

3838
# Optional: working directory, useful for monorepos
3939
# working-directory: somedir

.golangci.yml

-6
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,3 @@ issues:
7373
- error strings should not be capitalized or end with punctuation or a newline
7474
- Wrapf call needs 1 arg but has 2 args
7575
- cs.NegotiatedProtocolIsMutual is deprecated
76-
# golangci.com configuration
77-
# https://github.com/golangci/golangci/wiki/Configuration
78-
service:
79-
golangci-lint-version: 1.19.x # use the fixed version to not introduce new linters unexpectedly
80-
prepare:
81-
- echo "here I can run custom commands, but no preparation needed for this repo"

acme/api/account_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99
"net/http/httptest"
1010
"net/url"
1111
"testing"
@@ -263,7 +263,7 @@ func TestHandler_GetOrdersByAccountID(t *testing.T) {
263263

264264
assert.Equals(t, res.StatusCode, tc.statusCode)
265265

266-
body, err := ioutil.ReadAll(res.Body)
266+
body, err := io.ReadAll(res.Body)
267267
res.Body.Close()
268268
assert.FatalError(t, err)
269269

@@ -468,7 +468,7 @@ func TestHandler_NewAccount(t *testing.T) {
468468

469469
assert.Equals(t, res.StatusCode, tc.statusCode)
470470

471-
body, err := ioutil.ReadAll(res.Body)
471+
body, err := io.ReadAll(res.Body)
472472
res.Body.Close()
473473
assert.FatalError(t, err)
474474

@@ -668,7 +668,7 @@ func TestHandler_GetOrUpdateAccount(t *testing.T) {
668668

669669
assert.Equals(t, res.StatusCode, tc.statusCode)
670670

671-
body, err := ioutil.ReadAll(res.Body)
671+
body, err := io.ReadAll(res.Body)
672672
res.Body.Close()
673673
assert.FatalError(t, err)
674674

acme/api/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
func link(url, typ string) string {
20-
return fmt.Sprintf("<%s>;rel=\"%s\"", url, typ)
20+
return fmt.Sprintf("<%s>;rel=%q", url, typ)
2121
}
2222

2323
// Clock that returns time in UTC rounded to seconds.

acme/api/handler_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"encoding/json"
88
"encoding/pem"
99
"fmt"
10-
"io/ioutil"
10+
"io"
1111
"net/http"
1212
"net/http/httptest"
1313
"net/url"
@@ -89,7 +89,7 @@ func TestHandler_GetDirectory(t *testing.T) {
8989

9090
assert.Equals(t, res.StatusCode, tc.statusCode)
9191

92-
body, err := ioutil.ReadAll(res.Body)
92+
body, err := io.ReadAll(res.Body)
9393
res.Body.Close()
9494
assert.FatalError(t, err)
9595

@@ -261,7 +261,7 @@ func TestHandler_GetAuthorization(t *testing.T) {
261261

262262
assert.Equals(t, res.StatusCode, tc.statusCode)
263263

264-
body, err := ioutil.ReadAll(res.Body)
264+
body, err := io.ReadAll(res.Body)
265265
res.Body.Close()
266266
assert.FatalError(t, err)
267267

@@ -404,7 +404,7 @@ func TestHandler_GetCertificate(t *testing.T) {
404404

405405
assert.Equals(t, res.StatusCode, tc.statusCode)
406406

407-
body, err := ioutil.ReadAll(res.Body)
407+
body, err := io.ReadAll(res.Body)
408408
res.Body.Close()
409409
assert.FatalError(t, err)
410410

@@ -660,7 +660,7 @@ func TestHandler_GetChallenge(t *testing.T) {
660660

661661
assert.Equals(t, res.StatusCode, tc.statusCode)
662662

663-
body, err := ioutil.ReadAll(res.Body)
663+
body, err := io.ReadAll(res.Body)
664664
res.Body.Close()
665665
assert.FatalError(t, err)
666666

acme/api/middleware.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"crypto/rsa"
66
"errors"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"net/url"
1010
"strings"
@@ -118,7 +118,7 @@ func (h *Handler) verifyContentType(next nextHTTP) nextHTTP {
118118
// parseJWS is a middleware that parses a request body into a JSONWebSignature struct.
119119
func (h *Handler) parseJWS(next nextHTTP) nextHTTP {
120120
return func(w http.ResponseWriter, r *http.Request) {
121-
body, err := ioutil.ReadAll(r.Body)
121+
body, err := io.ReadAll(r.Body)
122122
if err != nil {
123123
api.WriteError(w, acme.WrapErrorISE(err, "failed to read request body"))
124124
return
@@ -378,7 +378,7 @@ func (h *Handler) verifyAndExtractJWSPayload(next nextHTTP) nextHTTP {
378378
}
379379
ctx = context.WithValue(ctx, payloadContextKey, &payloadInfo{
380380
value: payload,
381-
isPostAsGet: string(payload) == "",
381+
isPostAsGet: len(payload) == 0,
382382
isEmptyJSON: string(payload) == "{}",
383383
})
384384
next(w, r.WithContext(ctx))

acme/api/middleware_test.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"fmt"
1010
"io"
11-
"io/ioutil"
1211
"net/http"
1312
"net/http/httptest"
1413
"net/url"
@@ -148,7 +147,7 @@ func TestHandler_addNonce(t *testing.T) {
148147

149148
assert.Equals(t, res.StatusCode, tc.statusCode)
150149

151-
body, err := ioutil.ReadAll(res.Body)
150+
body, err := io.ReadAll(res.Body)
152151
res.Body.Close()
153152
assert.FatalError(t, err)
154153

@@ -205,7 +204,7 @@ func TestHandler_addDirLink(t *testing.T) {
205204

206205
assert.Equals(t, res.StatusCode, tc.statusCode)
207206

208-
body, err := ioutil.ReadAll(res.Body)
207+
body, err := io.ReadAll(res.Body)
209208
res.Body.Close()
210209
assert.FatalError(t, err)
211210

@@ -332,7 +331,7 @@ func TestHandler_verifyContentType(t *testing.T) {
332331

333332
assert.Equals(t, res.StatusCode, tc.statusCode)
334333

335-
body, err := ioutil.ReadAll(res.Body)
334+
body, err := io.ReadAll(res.Body)
336335
res.Body.Close()
337336
assert.FatalError(t, err)
338337

@@ -400,7 +399,7 @@ func TestHandler_isPostAsGet(t *testing.T) {
400399

401400
assert.Equals(t, res.StatusCode, tc.statusCode)
402401

403-
body, err := ioutil.ReadAll(res.Body)
402+
body, err := io.ReadAll(res.Body)
404403
res.Body.Close()
405404
assert.FatalError(t, err)
406405

@@ -490,7 +489,7 @@ func TestHandler_parseJWS(t *testing.T) {
490489

491490
assert.Equals(t, res.StatusCode, tc.statusCode)
492491

493-
body, err := ioutil.ReadAll(res.Body)
492+
body, err := io.ReadAll(res.Body)
494493
res.Body.Close()
495494
assert.FatalError(t, err)
496495

@@ -689,7 +688,7 @@ func TestHandler_verifyAndExtractJWSPayload(t *testing.T) {
689688

690689
assert.Equals(t, res.StatusCode, tc.statusCode)
691690

692-
body, err := ioutil.ReadAll(res.Body)
691+
body, err := io.ReadAll(res.Body)
693692
res.Body.Close()
694693
assert.FatalError(t, err)
695694

@@ -891,7 +890,7 @@ func TestHandler_lookupJWK(t *testing.T) {
891890

892891
assert.Equals(t, res.StatusCode, tc.statusCode)
893892

894-
body, err := ioutil.ReadAll(res.Body)
893+
body, err := io.ReadAll(res.Body)
895894
res.Body.Close()
896895
assert.FatalError(t, err)
897896

@@ -1087,7 +1086,7 @@ func TestHandler_extractJWK(t *testing.T) {
10871086

10881087
assert.Equals(t, res.StatusCode, tc.statusCode)
10891088

1090-
body, err := ioutil.ReadAll(res.Body)
1089+
body, err := io.ReadAll(res.Body)
10911090
res.Body.Close()
10921091
assert.FatalError(t, err)
10931092

@@ -1454,7 +1453,7 @@ func TestHandler_validateJWS(t *testing.T) {
14541453

14551454
assert.Equals(t, res.StatusCode, tc.statusCode)
14561455

1457-
body, err := ioutil.ReadAll(res.Body)
1456+
body, err := io.ReadAll(res.Body)
14581457
res.Body.Close()
14591458
assert.FatalError(t, err)
14601459

acme/api/order_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"encoding/base64"
88
"encoding/json"
99
"fmt"
10-
"io/ioutil"
10+
"io"
1111
"net/http/httptest"
1212
"net/url"
1313
"reflect"
@@ -430,7 +430,7 @@ func TestHandler_GetOrder(t *testing.T) {
430430

431431
assert.Equals(t, res.StatusCode, tc.statusCode)
432432

433-
body, err := ioutil.ReadAll(res.Body)
433+
body, err := io.ReadAll(res.Body)
434434
res.Body.Close()
435435
assert.FatalError(t, err)
436436

@@ -1343,7 +1343,7 @@ func TestHandler_NewOrder(t *testing.T) {
13431343

13441344
assert.Equals(t, res.StatusCode, tc.statusCode)
13451345

1346-
body, err := ioutil.ReadAll(res.Body)
1346+
body, err := io.ReadAll(res.Body)
13471347
res.Body.Close()
13481348
assert.FatalError(t, err)
13491349

@@ -1633,7 +1633,7 @@ func TestHandler_FinalizeOrder(t *testing.T) {
16331633

16341634
assert.Equals(t, res.StatusCode, tc.statusCode)
16351635

1636-
body, err := ioutil.ReadAll(res.Body)
1636+
body, err := io.ReadAll(res.Body)
16371637
res.Body.Close()
16381638
assert.FatalError(t, err)
16391639

acme/challenge.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"encoding/json"
1313
"errors"
1414
"fmt"
15-
"io/ioutil"
15+
"io"
1616
"net"
1717
"net/http"
1818
"net/url"
@@ -89,7 +89,7 @@ func http01Validate(ctx context.Context, ch *Challenge, db DB, jwk *jose.JSONWeb
8989
"error doing http GET for url %s with status code %d", u, resp.StatusCode))
9090
}
9191

92-
body, err := ioutil.ReadAll(resp.Body)
92+
body, err := io.ReadAll(resp.Body)
9393
if err != nil {
9494
return WrapErrorISE(err, "error reading "+
9595
"response body for url %s", u)

acme/challenge_test.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"encoding/hex"
1616
"fmt"
1717
"io"
18-
"io/ioutil"
1918
"math/big"
2019
"net"
2120
"net/http"
@@ -707,7 +706,7 @@ func TestHTTP01Validate(t *testing.T) {
707706
vo: &ValidateChallengeOptions{
708707
HTTPGet: func(url string) (*http.Response, error) {
709708
return &http.Response{
710-
Body: ioutil.NopCloser(bytes.NewBufferString("foo")),
709+
Body: io.NopCloser(bytes.NewBufferString("foo")),
711710
}, nil
712711
},
713712
},
@@ -733,7 +732,7 @@ func TestHTTP01Validate(t *testing.T) {
733732
vo: &ValidateChallengeOptions{
734733
HTTPGet: func(url string) (*http.Response, error) {
735734
return &http.Response{
736-
Body: ioutil.NopCloser(bytes.NewBufferString("foo")),
735+
Body: io.NopCloser(bytes.NewBufferString("foo")),
737736
}, nil
738737
},
739738
},
@@ -775,7 +774,7 @@ func TestHTTP01Validate(t *testing.T) {
775774
vo: &ValidateChallengeOptions{
776775
HTTPGet: func(url string) (*http.Response, error) {
777776
return &http.Response{
778-
Body: ioutil.NopCloser(bytes.NewBufferString("foo")),
777+
Body: io.NopCloser(bytes.NewBufferString("foo")),
779778
}, nil
780779
},
781780
},
@@ -818,7 +817,7 @@ func TestHTTP01Validate(t *testing.T) {
818817
vo: &ValidateChallengeOptions{
819818
HTTPGet: func(url string) (*http.Response, error) {
820819
return &http.Response{
821-
Body: ioutil.NopCloser(bytes.NewBufferString(expKeyAuth)),
820+
Body: io.NopCloser(bytes.NewBufferString(expKeyAuth)),
822821
}, nil
823822
},
824823
},
@@ -860,7 +859,7 @@ func TestHTTP01Validate(t *testing.T) {
860859
vo: &ValidateChallengeOptions{
861860
HTTPGet: func(url string) (*http.Response, error) {
862861
return &http.Response{
863-
Body: ioutil.NopCloser(bytes.NewBufferString(expKeyAuth)),
862+
Body: io.NopCloser(bytes.NewBufferString(expKeyAuth)),
864863
}, nil
865864
},
866865
},

0 commit comments

Comments
 (0)