From 4a09880fc356d04beefbc92227fd071921d446e5 Mon Sep 17 00:00:00 2001 From: Gustavo Bazan Date: Thu, 19 May 2022 13:28:56 +0100 Subject: [PATCH] task: update golangci-lint --- .github/workflows/golangci-lint.yml | 9 ++++++--- Makefile | 2 +- digest.go | 25 ++++++++++++------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 02c160d..9690355 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -11,8 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: 1.18 - name: golangci-lint - uses: golangci/golangci-lint-action@v2.5.1 + uses: golangci/golangci-lint-action@v3.2.0 with: - version: v1.42.0 - args: --timeout 2m0s + version: v1.46.2 diff --git a/Makefile b/Makefile index b631ce4..299a2c5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html -GOLANGCI_VERSION=v1.42.0 +GOLANGCI_VERSION=v1.46.2 COVERAGE=coverage.out .PHONY: setup diff --git a/digest.go b/digest.go index 452795e..793a4b6 100644 --- a/digest.go +++ b/digest.go @@ -80,7 +80,6 @@ import ( "fmt" "hash" "io" - "io/ioutil" "net/http" "strings" ) @@ -250,21 +249,21 @@ func (c *credentials) authorize() (string, error) { if err != nil { return "", ErrAlgNotImplemented } - sl := []string{fmt.Sprintf(`username="%s"`, c.Username)} - sl = append(sl, fmt.Sprintf(`realm="%s"`, c.Realm), - fmt.Sprintf(`nonce="%s"`, c.Nonce), - fmt.Sprintf(`uri="%s"`, c.DigestURI), - fmt.Sprintf(`response="%s"`, resp)) + sl := []string{fmt.Sprintf(`username=%q`, c.Username)} + sl = append(sl, fmt.Sprintf(`realm=%q`, c.Realm), + fmt.Sprintf(`nonce=%q`, c.Nonce), + fmt.Sprintf(`uri=%q`, c.DigestURI), + fmt.Sprintf(`response=%q`, resp)) if c.Algorithm != "" { - sl = append(sl, fmt.Sprintf(`algorithm="%s"`, c.Algorithm)) + sl = append(sl, fmt.Sprintf(`algorithm=%q`, c.Algorithm)) } if c.Opaque != "" { - sl = append(sl, fmt.Sprintf(`opaque="%s"`, c.Opaque)) + sl = append(sl, fmt.Sprintf(`opaque=%q`, c.Opaque)) } if c.MessageQop != "" { sl = append(sl, fmt.Sprintf("qop=%s", c.MessageQop), fmt.Sprintf("nc=%08x", c.NonceCount), - fmt.Sprintf(`cnonce="%s"`, c.Cnonce)) + fmt.Sprintf(`cnonce=%q`, c.Cnonce)) } return fmt.Sprintf("Digest %s", strings.Join(sl, ", ")), nil } @@ -315,12 +314,12 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { // before the RoundTrip(origReq) call. If GetBody is unavailable, read // the body into a memory buffer and use it for both requests. if req.Body != nil && req.GetBody == nil { - body, err := ioutil.ReadAll(req.Body) + body, err := io.ReadAll(req.Body) if err != nil { return nil, err } - req.Body = ioutil.NopCloser(bytes.NewBuffer(body)) - origReq.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + req.Body = io.NopCloser(bytes.NewBuffer(body)) + origReq.Body = io.NopCloser(bytes.NewBuffer(body)) } // Make a request to get the 401 that contains the challenge. challenge, resp, err := t.fetchChallenge(req) @@ -375,7 +374,7 @@ func (t *Transport) fetchChallenge(req *http.Request) (string, *http.Response, e // won't reuse it anyway. const maxBodySlurpSize = 2 << 10 if resp.ContentLength == -1 || resp.ContentLength <= maxBodySlurpSize { - _, _ = io.CopyN(ioutil.Discard, resp.Body, maxBodySlurpSize) + _, _ = io.CopyN(io.Discard, resp.Body, maxBodySlurpSize) } resp.Body.Close()