Skip to content

Commit

Permalink
replace deprecated io/ioutil calls
Browse files Browse the repository at this point in the history
  • Loading branch information
pvormste committed Apr 17, 2023
1 parent 7f974c9 commit 824136c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions internal/pkg/unsafeparser/unsafeparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package unsafeparser

import (
"io/ioutil"
"os"

"github.com/TykTechnologies/graphql-go-tools/pkg/ast"
"github.com/TykTechnologies/graphql-go-tools/pkg/astparser"
Expand All @@ -25,7 +25,7 @@ func ParseGraphqlDocumentBytes(input []byte) ast.Document {
}

func ParseGraphqlDocumentFile(filePath string) ast.Document {
fileBytes, err := ioutil.ReadFile(filePath)
fileBytes, err := os.ReadFile(filePath)
if err != nil {
panic(err)
}
Expand Down
9 changes: 4 additions & 5 deletions pkg/astvalidation/reference/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand All @@ -23,13 +22,13 @@ func main() {
workingDir = filepath.Join(currDir, "pkg/astvalidation/reference/__tests__")
}

dir, err := ioutil.ReadDir(workingDir)
dir, err := os.ReadDir(workingDir)
if err != nil {
log.Fatal(err)
}

replacementsPath := workingDir + "/../replacements.yml"
replacementContent, _ := ioutil.ReadFile(replacementsPath)
replacementContent, _ := os.ReadFile(replacementsPath)

var replacements []Replacement
if err := yaml.Unmarshal(replacementContent, &replacements); err != nil {
Expand Down Expand Up @@ -112,7 +111,7 @@ func skipRule(name string) bool {
// processFile - convert and save reference test file
func processFile(workingDir string, filename string, replacements Replacements) {
fPath := filepath.Join(workingDir, filename)
fileContent, _ := ioutil.ReadFile(fPath)
fileContent, _ := os.ReadFile(fPath)

testName := strings.TrimSuffix(strings.Split(filepath.Base(filename), ".")[0], "-test")

Expand All @@ -129,7 +128,7 @@ func processFile(workingDir string, filename string, replacements Replacements)
result := converter.iterateLines(testName, content)

outFileName := testName + "_test.go"
err := ioutil.WriteFile(filepath.Join(outDir, outFileName), []byte(result), os.ModePerm)
err := os.WriteFile(filepath.Join(outDir, outFileName), []byte(result), os.ModePerm)
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/execution/datasource/datasource_graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"io"
"io/ioutil"
"net/http"

"github.com/buger/jsonparser"
Expand Down Expand Up @@ -440,9 +439,9 @@ func (g *GraphQLDataSource) Resolve(ctx context.Context, args ResolverArgs, out
)
return n, err
}
data, err := ioutil.ReadAll(res.Body)
data, err := io.ReadAll(res.Body)
if err != nil {
g.Log.Error("GraphQLDataSource.ioutil.ReadAll",
g.Log.Error("GraphQLDataSource.io.ReadAll",
log.Error(err),
)
return n, err
Expand Down

0 comments on commit 824136c

Please sign in to comment.