From a12f49720c6936947d9bb65aa214618c633f9632 Mon Sep 17 00:00:00 2001 From: Andriy CF <163290126+ab-cf@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:05:56 +0100 Subject: [PATCH] Fix linting issues (#9) * Update linters * Replace deprecated ioutil --- .github/workflows/build.yml | 18 +++++++++++------- backend.go | 4 ++-- backend_test.go | 4 ++-- go.mod | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c39b56a..4bd33ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,20 +11,24 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Check code formatting run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi - name: Lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v4 with: - version: v1.29 + version: v1.54 test: strategy: matrix: go-version: - - 1.14.x - - 1.15.x + - 1.16.x + - 1.17.x + - 1.18.x + - 1.19.x + - 1.20.x + - 1.21.x os: - ubuntu-latest - macos-latest @@ -32,10 +36,10 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Test run: go test ./... diff --git a/backend.go b/backend.go index 1550ddb..67d7c27 100644 --- a/backend.go +++ b/backend.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" ) @@ -56,7 +56,7 @@ func (b *APIKeyBackend) Request(ctx context.Context, method, path string, payloa return fmt.Errorf("unable to perform HTTP request: %w", err) } defer resp.Body.Close() - body, err = ioutil.ReadAll(resp.Body) + body, err = io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("unable to read from HTTP response body: %w", err) } diff --git a/backend_test.go b/backend_test.go index 411ccd9..d29c587 100644 --- a/backend_test.go +++ b/backend_test.go @@ -3,7 +3,7 @@ package hasty import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "strings" @@ -24,7 +24,7 @@ type testReq struct { func TestAPIKeyBackend(t *testing.T) { reqs := make(chan testReq, 1) ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - body, _ := ioutil.ReadAll(r.Body) + body, _ := io.ReadAll(r.Body) reqs <- testReq{ method: r.Method, path: r.URL.Path, diff --git a/go.mod b/go.mod index c45c283..73c6185 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/cloudfactory/hasty-go -go 1.14 +go 1.21