Skip to content

Commit

Permalink
Use os.ReadFile instead of ioutil.ReadFile
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <[email protected]>
  • Loading branch information
fenollp committed Aug 8, 2023
1 parent b81a83e commit 1cfdab5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions openapi2/openapi2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openapi2_test
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"reflect"

"github.com/invopop/yaml"
Expand All @@ -12,7 +12,7 @@ import (
)

func Example() {
input, err := ioutil.ReadFile("testdata/swagger.json")
input, err := os.ReadFile("testdata/swagger.json")
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions openapi3/issue241_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package openapi3_test

import (
"bytes"
"io/ioutil"
"os"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -12,7 +12,7 @@ import (
)

func TestIssue241(t *testing.T) {
data, err := ioutil.ReadFile("testdata/issue241.yml")
data, err := os.ReadFile("testdata/issue241.yml")
require.NoError(t, err)

loader := openapi3.NewLoader()
Expand Down
4 changes: 2 additions & 2 deletions openapi3/loader_read_from_uri_func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package openapi3

import (
"fmt"
"io/ioutil"
"net/url"
"os"
"path/filepath"
"testing"

Expand All @@ -14,7 +14,7 @@ func TestLoaderReadFromURIFunc(t *testing.T) {
loader := NewLoader()
loader.IsExternalRefsAllowed = true
loader.ReadFromURIFunc = func(loader *Loader, url *url.URL) ([]byte, error) {
return ioutil.ReadFile(filepath.Join("testdata", url.Path))
return os.ReadFile(filepath.Join("testdata", url.Path))
}
doc, err := loader.LoadFromFile("recursiveRef/openapi.yml")
require.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion openapi3/loader_uri_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"os"
"path/filepath"
"sync"
)
Expand Down Expand Up @@ -75,7 +76,7 @@ func ReadFromFile(loader *Loader, location *url.URL) ([]byte, error) {
if location.Scheme != "" && location.Scheme != "file" {
return nil, ErrURINotSupported
}
return ioutil.ReadFile(location.Path)
return os.ReadFile(location.Path)
}

// URIMapCache returns a ReadFromURIFunc that caches the contents read from URI
Expand Down

0 comments on commit 1cfdab5

Please sign in to comment.