Skip to content

Commit 19b089d

Browse files
committed
fix: lint
1 parent d4395d3 commit 19b089d

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

base64loader/base64loader.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// registering its Loaders.
55
//
66
// To use base64loader, link this package into your program:
7-
// import _ "github.com/ory/jsonschema/v3/base64loader"
87
//
8+
// import _ "github.com/ory/jsonschema/v3/base64loader"
99
package base64loader
1010

1111
import (
@@ -14,7 +14,6 @@ import (
1414
"encoding/base64"
1515
"fmt"
1616
"io"
17-
"io/ioutil"
1817
"strings"
1918

2019
"github.com/ory/jsonschema/v3"
@@ -31,7 +30,7 @@ func Load(ctx context.Context, url string) (_ io.ReadCloser, err error) {
3130
return nil, fmt.Errorf("unable to decode std encoded base64 string: %s", err)
3231
}
3332

34-
return ioutil.NopCloser(bytes.NewBuffer(raw)), nil
33+
return io.NopCloser(bytes.NewBuffer(raw)), nil
3534
}
3635

3736
func init() {

httploader/httploader_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package httploader
33
import (
44
"context"
55
"errors"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"net/http/httptest"
99
"testing"
@@ -13,12 +13,12 @@ import (
1313
"github.com/stretchr/testify/require"
1414
)
1515

16-
var fooErr = errors.New("foo")
16+
var errFoo = errors.New("foo")
1717

1818
type rt struct{}
1919

2020
func (r rt) RoundTrip(_ *http.Request) (*http.Response, error) {
21-
return nil, fooErr
21+
return nil, errFoo
2222
}
2323

2424
var _ http.RoundTripper = new(rt)
@@ -34,7 +34,7 @@ func TestHTTPLoader(t *testing.T) {
3434
res, err := Load(context.WithValue(context.Background(), ContextKey, retryablehttp.NewClient()), ts.URL)
3535
require.NoError(t, err)
3636
defer res.Close()
37-
body, err := ioutil.ReadAll(res)
37+
body, err := io.ReadAll(res)
3838
require.NoError(t, err)
3939
return string(body)
4040
}
@@ -45,9 +45,9 @@ func TestHTTPLoader(t *testing.T) {
4545
hc.RetryMax = 1
4646
hc.HTTPClient.Transport = new(rt)
4747
_, err := Load(context.WithValue(context.Background(), ContextKey, hc), ts.URL)
48-
require.ErrorIs(t, err, fooErr)
48+
require.ErrorIs(t, err, errFoo)
4949

5050
_, err = Load(context.WithValue(context.Background(), ContextKey, new(struct{})), ts.URL)
51-
require.Error(t, err, fooErr)
51+
require.Error(t, err, errFoo)
5252
assert.Equal(t, "invalid context value for github.com/ory/jsonschema/v3/httploader.HTTPClient expected *retryablehttp.Client but got: *struct {}", err.Error())
5353
}

schema_test.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"encoding/json"
1111
"errors"
1212
"io"
13-
"io/ioutil"
1413
"net/http"
1514
"net/http/httptest"
1615
"net/url"
@@ -22,10 +21,8 @@ import (
2221

2322
"github.com/hashicorp/go-retryablehttp"
2423

25-
"github.com/ory/jsonschema/v3/httploader"
26-
2724
"github.com/ory/jsonschema/v3"
28-
_ "github.com/ory/jsonschema/v3/httploader"
25+
"github.com/ory/jsonschema/v3/httploader"
2926
)
3027

3128
var draft4, draft6, draft7 []byte
@@ -34,15 +31,15 @@ var ctx = context.WithValue(context.Background(), httploader.ContextKey, retryab
3431

3532
func init() {
3633
var err error
37-
draft4, err = ioutil.ReadFile("testdata/draft4.json")
34+
draft4, err = os.ReadFile("testdata/draft4.json")
3835
if err != nil {
3936
panic(err)
4037
}
41-
draft6, err = ioutil.ReadFile("testdata/draft6.json")
38+
draft6, err = os.ReadFile("testdata/draft6.json")
4239
if err != nil {
4340
panic(err)
4441
}
45-
draft7, err = ioutil.ReadFile("testdata/draft7.json")
42+
draft7, err = os.ReadFile("testdata/draft7.json")
4643
if err != nil {
4744
panic(err)
4845
}
@@ -74,7 +71,7 @@ func testFolder(t *testing.T, folder string, draft *jsonschema.Draft) {
7471
server := &http.Server{Addr: "localhost:1234", Handler: http.FileServer(http.Dir("testdata/remotes"))}
7572
go func() {
7673
if err := server.ListenAndServe(); err != http.ErrServerClosed {
77-
t.Fatal(err)
74+
t.Error(err)
7875
}
7976
}()
8077
defer server.Close()
@@ -92,7 +89,7 @@ func testFolder(t *testing.T, folder string, draft *jsonschema.Draft) {
9289
}
9390

9491
t.Log(info.Name())
95-
data, err := ioutil.ReadFile(path)
92+
data, err := os.ReadFile(path)
9693
if err != nil {
9794
t.Errorf(" FAIL: %v\n", err)
9895
return nil
@@ -217,7 +214,7 @@ func TestInvalidSchema(t *testing.T) {
217214
Schema json.RawMessage
218215
Fragment string
219216
}
220-
data, err := ioutil.ReadFile("testdata/invalid_schemas.json")
217+
data, err := os.ReadFile("testdata/invalid_schemas.json")
221218
if err != nil {
222219
t.Fatal(err)
223220
}
@@ -307,7 +304,7 @@ func TestValidateInterface(t *testing.T) {
307304
}
308305
for _, file := range files {
309306
t.Log(filepath.Base(file))
310-
data, err := ioutil.ReadFile(file)
307+
data, err := os.ReadFile(file)
311308
if err != nil {
312309
t.Errorf(" FAIL: %v\n", err)
313310
return
@@ -538,9 +535,9 @@ func TestCompiler_LoadURL(t *testing.T) {
538535
c.LoadURL = func(ctx context.Context, s string) (io.ReadCloser, error) {
539536
switch s {
540537
case "base.json":
541-
return ioutil.NopCloser(strings.NewReader(base)), nil
538+
return io.NopCloser(strings.NewReader(base)), nil
542539
case "schema.json":
543-
return ioutil.NopCloser(strings.NewReader(schema)), nil
540+
return io.NopCloser(strings.NewReader(schema)), nil
544541
default:
545542
return nil, errors.New("unsupported schema")
546543
}
@@ -561,7 +558,7 @@ func TestSchemaReferencesDrafts(t *testing.T) {
561558
c := jsonschema.NewCompiler()
562559
file := "testdata/reference_draft.json"
563560
t.Log(filepath.Base(file))
564-
data, err := ioutil.ReadFile(file)
561+
data, err := os.ReadFile(file)
565562
if err != nil {
566563
t.Errorf(" FAIL: %v\n", err)
567564
return

0 commit comments

Comments
 (0)