chore: switch from iouitil to io.ReadAll (#272)
removed a TODO: switch to io.ReadAll and drop go1.15 support
This commit is contained in:
parent
cdf2af6c2c
commit
df5a09f813
7 changed files with 15 additions and 20 deletions
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: ['1.15', '1.16', '1.17', '1.18', '1.19']
|
go: ['1.16', '1.17', '1.18', '1.19']
|
||||||
name: Go ${{ matrix.go }} test
|
name: Go ${{ matrix.go }} test
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
|
@ -87,8 +87,7 @@ Versions that also build are marked with :warning:.
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
|---------|--------------------|
|
|---------|--------------------|
|
||||||
| <1.15 | :x: |
|
| <1.16 | :x: |
|
||||||
| 1.15 | :warning: |
|
|
||||||
| 1.16 | :warning: |
|
| 1.16 | :warning: |
|
||||||
| 1.17 | :warning: |
|
| 1.17 | :warning: |
|
||||||
| 1.18 | :white_check_mark: |
|
| 1.18 | :white_check_mark: |
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -71,7 +71,7 @@ func main() {
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
key, err := ioutil.ReadAll(file)
|
key, err := io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
@ -161,7 +161,7 @@ func callExampleEndpoint(client *http.Client, testURL string) (interface{}, erro
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
||||||
module github.com/zitadel/oidc
|
module github.com/zitadel/oidc
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/golang/mock v1.6.0
|
github.com/golang/mock v1.6.0
|
||||||
|
|
|
@ -3,7 +3,7 @@ package client
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -92,8 +92,7 @@ func CallEndSessionEndpoint(request interface{}, authFn interface{}, caller EndS
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
if resp.StatusCode < 200 || resp.StatusCode >= 400 {
|
if resp.StatusCode < 200 || resp.StatusCode >= 400 {
|
||||||
// TODO: switch to io.ReadAll when go1.15 support is retired
|
body, err := io.ReadAll(resp.Body)
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -139,8 +138,7 @@ func CallRevokeEndpoint(request interface{}, authFn interface{}, caller RevokeCa
|
||||||
// "The content of the response body is ignored by the client as all
|
// "The content of the response body is ignored by the client as all
|
||||||
// necessary information is conveyed in the response code."
|
// necessary information is conveyed in the response code."
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
// TODO: switch to io.ReadAll when go1.15 support is retired
|
body, err := io.ReadAll(resp.Body)
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("revoke returned status %d and text: %s", resp.StatusCode, string(body))
|
return fmt.Errorf("revoke returned status %d and text: %s", resp.StatusCode, string(body))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package rp_test
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -209,8 +210,7 @@ func getRedirect(t *testing.T, desc string, httpClient *http.Client, uri *url.UR
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if t.Failed() {
|
if t.Failed() {
|
||||||
// TODO: switch to io.ReadAll when go1.15 support is dropped
|
body, _ := io.ReadAll(resp.Body)
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
|
||||||
t.Logf("%s: GET %s: body: %s", desc, uri, string(body))
|
t.Logf("%s: GET %s: body: %s", desc, uri, string(body))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -233,8 +233,7 @@ func getForm(t *testing.T, desc string, httpClient *http.Client, uri *url.URL) [
|
||||||
require.NoErrorf(t, err, "%s: GET %s", desc, uri)
|
require.NoErrorf(t, err, "%s: GET %s", desc, uri)
|
||||||
//nolint:errcheck
|
//nolint:errcheck
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
// TODO: switch to io.ReadAll when go1.15 support is dropped
|
body, err := io.ReadAll(resp.Body)
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
|
||||||
require.NoError(t, err, "%s: read GET %s", desc, uri)
|
require.NoError(t, err, "%s: read GET %s", desc, uri)
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
@ -256,8 +255,7 @@ func fillForm(t *testing.T, desc string, httpClient *http.Client, body []byte, u
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
defer func() {
|
defer func() {
|
||||||
if t.Failed() {
|
if t.Failed() {
|
||||||
// TODO: switch to io.ReadAll when go1.15 support is dropped
|
body, _ := io.ReadAll(resp.Body)
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
|
||||||
t.Logf("%s: GET %s: body: %s", desc, uri, string(body))
|
t.Logf("%s: GET %s: body: %s", desc, uri, string(body))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -60,7 +60,7 @@ func HttpRequest(client *http.Client, req *http.Request, response interface{}) e
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to read response body: %v", err)
|
return fmt.Errorf("unable to read response body: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue