Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use os.ReadFile instead of ioutil.ReadFile #691

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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