Skip to content

Commit

Permalink
Drop support for Go < 1.17 and add official tests on go 1.19 (#211)
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
  • Loading branch information
LKaemmerling committed Sep 19, 2022
1 parent 2f419b0 commit 3446580
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.13, 1.14, 1.15, 1.16, 1.17, 1.18]
go-version: [1.17, 1.18, 1.19]
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
9 changes: 4 additions & 5 deletions hcloud/client.go
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"math"
"net/http"
"net/http/httputil"
Expand Down Expand Up @@ -222,7 +221,7 @@ func (c *Client) Do(r *http.Request, v interface{}) (*Response, error) {
var body []byte
var err error
if r.ContentLength > 0 {
body, err = ioutil.ReadAll(r.Body)
body, err = io.ReadAll(r.Body)
if err != nil {
r.Body.Close()
return nil, err
Expand All @@ -231,7 +230,7 @@ func (c *Client) Do(r *http.Request, v interface{}) (*Response, error) {
}
for {
if r.ContentLength > 0 {
r.Body = ioutil.NopCloser(bytes.NewReader(body))
r.Body = io.NopCloser(bytes.NewReader(body))
}

if c.debugWriter != nil {
Expand All @@ -247,13 +246,13 @@ func (c *Client) Do(r *http.Request, v interface{}) (*Response, error) {
return nil, err
}
response := &Response{Response: resp}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
resp.Body.Close()
return response, err
}
resp.Body.Close()
resp.Body = ioutil.NopCloser(bytes.NewReader(body))
resp.Body = io.NopCloser(bytes.NewReader(body))

if c.debugWriter != nil {
dumpResp, err := httputil.DumpResponse(resp, true)
Expand Down
4 changes: 2 additions & 2 deletions hcloud/client_test.go
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -304,7 +304,7 @@ func TestClientDoPost(t *testing.T) {
callCount++
w.Header().Set("Content-Type", "application/json")
var dat map[string]interface{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
r.Body.Close()
if err != nil {
t.Error(err)
Expand Down
4 changes: 2 additions & 2 deletions hcloud/metadata/client.go
Expand Up @@ -2,7 +2,7 @@ package metadata

import (
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"strconv"
Expand Down Expand Up @@ -73,7 +73,7 @@ func (c *Client) get(path string) (string, error) {
return "", err
}
defer resp.Body.Close()
bodyBytes, err := ioutil.ReadAll(resp.Body)
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 3446580

Please sign in to comment.