Skip to content

Commit

Permalink
GitHub Actions: Raise Go versions to v1.18 and v1.19 (#125)
Browse files Browse the repository at this point in the history
* GitHub Actions: Raise Go versions to v1.18 and v1.19

* GitHub Actions: Only run once on a Pull Request

* Fix "package io/ioutil is deprecated"

package io/ioutil is deprecated: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details.  (SA1019)

* go fmt
  • Loading branch information
andygrunwald authored Sep 21, 2022
1 parent 5de64ee commit 41749a6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: Testing

on:
push:
branches:
- main
pull_request:
workflow_dispatch:
schedule:
- cron: "5 1 * * *"

Expand All @@ -12,7 +15,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.18', '1.17' ]
go: [ '1.19', '1.18' ]

steps:
- uses: actions/checkout@v3
Expand All @@ -37,7 +40,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.18', '1.17' ]
go: [ '1.19', '1.18' ]

steps:
- uses: actions/checkout@v3
Expand All @@ -61,7 +64,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.18', '1.17' ]
go: [ '1.19', '1.18' ]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -89,7 +92,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.18', '1.17' ]
go: [ '1.19', '1.18' ]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gerrit
import (
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
)

Expand Down Expand Up @@ -911,7 +911,7 @@ func (s *ChangesService) change(tail string, changeID string, input interface{})
return nil, resp, err
}
if resp.StatusCode == http.StatusConflict {
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return v, resp, err
}
Expand Down
1 change: 0 additions & 1 deletion changes_attention.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type AttentionSetInput struct {
}

// RemoveAttention deletes a single user from the attention set of a change.
//
// AttentionSetInput.Input must be provided
//
// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#remove-from-attention-set
Expand Down
4 changes: 2 additions & 2 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gerrit
import (
"bytes"
"encoding/json"
"io/ioutil"
"io"
"net/url"
"time"
)
Expand Down Expand Up @@ -142,7 +142,7 @@ func (events *EventsLogService) GetEvents(options *EventsLogOptions) ([]EventInf
return info, response, failures, err
}

body, err := ioutil.ReadAll(response.Body)
body, err := io.ReadAll(response.Body)
defer response.Body.Close() // nolint: errcheck
if err != nil {
return info, response, failures, err
Expand Down
7 changes: 3 additions & 4 deletions gerrit.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"reflect"
Expand Down Expand Up @@ -372,7 +371,7 @@ func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) {
}
} else {
var body []byte
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
if err != nil {
// even though there was an error, we still return the response
// in case the caller wants to inspect it further
Expand Down Expand Up @@ -430,8 +429,8 @@ func (c *Client) addAuthentication(req *http.Request) error {
// When the function exits discard the rest of the
// body and close it. This should cause go to
// reuse the connection.
defer io.Copy(ioutil.Discard, response.Body) // nolint: errcheck
defer response.Body.Close() // nolint: errcheck
defer io.Copy(io.Discard, response.Body) // nolint: errcheck
defer response.Body.Close() // nolint: errcheck

if response.StatusCode == http.StatusUnauthorized {
authorization, err := c.Authentication.digestAuthHeader(response)
Expand Down
6 changes: 3 additions & 3 deletions gerrit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -405,7 +405,7 @@ func TestNewRequest(t *testing.T) {
}

// Test that body was JSON encoded
body, _ := ioutil.ReadAll(req.Body)
body, _ := io.ReadAll(req.Body)
if got, want := string(body), outBody; got != want {
t.Errorf("NewRequest Body is %v, want %v", got, want)
}
Expand All @@ -426,7 +426,7 @@ func TestNewRawPutRequest(t *testing.T) {
}

// Test that body was JSON encoded
body, _ := ioutil.ReadAll(req.Body)
body, _ := io.ReadAll(req.Body)
if got, want := string(body), "test raw PUT contents"; got != want {
t.Errorf("NewRequest Body is %v, want %v", got, want)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/andygrunwald/go-gerrit

go 1.15
go 1.16

require github.com/google/go-querystring v1.1.0

0 comments on commit 41749a6

Please sign in to comment.