diff --git a/v2/examples/chat/util.go b/v2/examples/chat/util.go index 562fc149a..2dc74e6f7 100644 --- a/v2/examples/chat/util.go +++ b/v2/examples/chat/util.go @@ -2,7 +2,6 @@ package chat import ( "encoding/json" - "io/ioutil" "os" "path/filepath" "strings" @@ -63,7 +62,7 @@ func LoadSchemaFromExamplesDirectoryWithinPkg() ([]byte, error) { } absolutePath := filepath.Join(strings.Split(wd, "pkg")[0], chatExampleDirectoryRelativePath, "schema.graphql") - return ioutil.ReadFile(absolutePath) + return os.ReadFile(absolutePath) } func GraphQLRequestForOperation(operation string) ([]byte, error) { diff --git a/v2/examples/federation/gateway/datasource_poller.go b/v2/examples/federation/gateway/datasource_poller.go index a2ecca602..f2fb0d15c 100644 --- a/v2/examples/federation/gateway/datasource_poller.go +++ b/v2/examples/federation/gateway/datasource_poller.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "net/http" "strings" @@ -206,7 +206,7 @@ func (d *DatasourcePollerPoller) fetchServiceSDL(ctx context.Context, serviceURL Errors GQLErr `json:"errors,omitempty"` } - bs, err := ioutil.ReadAll(resp.Body) + bs, err := io.ReadAll(resp.Body) if err != nil { return "", fmt.Errorf("read bytes: %v", err) } diff --git a/v2/examples/kafka_pubsub/main.go b/v2/examples/kafka_pubsub/main.go index a87df8935..90b68d753 100644 --- a/v2/examples/kafka_pubsub/main.go +++ b/v2/examples/kafka_pubsub/main.go @@ -5,7 +5,7 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" + "io" "log" "math/rand" "os" @@ -102,7 +102,7 @@ func main() { // Parse command line parameters f := flag.NewFlagSet(os.Args[0], flag.ContinueOnError) - f.SetOutput(ioutil.Discard) + f.SetOutput(io.Discard) f.BoolVar(&args.help, "h", false, "") f.BoolVar(&args.help, "help", false, "") f.StringVar(&args.products, "p", "", "") diff --git a/v2/examples/kafka_pubsub/transactional_producer/main.go b/v2/examples/kafka_pubsub/transactional_producer/main.go index 49ea2a633..b334cd067 100644 --- a/v2/examples/kafka_pubsub/transactional_producer/main.go +++ b/v2/examples/kafka_pubsub/transactional_producer/main.go @@ -5,7 +5,7 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" + "io" "log" "math/rand" "os" @@ -57,7 +57,7 @@ func main() { // Parse command line parameters f := flag.NewFlagSet(os.Args[0], flag.ContinueOnError) - f.SetOutput(ioutil.Discard) + f.SetOutput(io.Discard) f.BoolVar(&args.help, "h", false, "") f.BoolVar(&args.help, "help", false, "") f.BoolVar(&args.enableTransaction, "enable-transaction", false, "") diff --git a/v2/internal/pkg/unsafeparser/unsafeparser.go b/v2/internal/pkg/unsafeparser/unsafeparser.go index 1999aa91e..b115856e7 100644 --- a/v2/internal/pkg/unsafeparser/unsafeparser.go +++ b/v2/internal/pkg/unsafeparser/unsafeparser.go @@ -2,7 +2,7 @@ package unsafeparser import ( - "io/ioutil" + "os" "github.com/wundergraph/graphql-go-tools/v2/pkg/ast" "github.com/wundergraph/graphql-go-tools/v2/pkg/astparser" @@ -26,7 +26,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) } diff --git a/v2/pkg/astparser/parser_test.go b/v2/pkg/astparser/parser_test.go index 1c8fafc00..95eb0ecd1 100644 --- a/v2/pkg/astparser/parser_test.go +++ b/v2/pkg/astparser/parser_test.go @@ -2,7 +2,7 @@ package astparser import ( "fmt" - "io/ioutil" + "os" "testing" "github.com/stretchr/testify/assert" @@ -2322,7 +2322,7 @@ func TestErrorReport(t *testing.T) { func TestParseStarwars(t *testing.T) { - starWarsSchema, err := ioutil.ReadFile("./testdata/starwars.schema.graphql") + starWarsSchema, err := os.ReadFile("./testdata/starwars.schema.graphql") if err != nil { t.Fatal(err) } @@ -2336,7 +2336,7 @@ func TestParseStarwars(t *testing.T) { func TestParseTodo(t *testing.T) { inputFileName := "./testdata/todo.graphql" - schema, err := ioutil.ReadFile(inputFileName) + schema, err := os.ReadFile(inputFileName) if err != nil { t.Fatal(err) } @@ -2352,7 +2352,7 @@ func TestParseTodo(t *testing.T) { func BenchmarkParseStarwars(b *testing.B) { inputFileName := "./testdata/starwars.schema.graphql" - starwarsSchema, err := ioutil.ReadFile(inputFileName) + starwarsSchema, err := os.ReadFile(inputFileName) if err != nil { b.Fatal(err) } @@ -2379,7 +2379,7 @@ func BenchmarkParseStarwars(b *testing.B) { func BenchmarkParseGithub(b *testing.B) { inputFileName := "./testdata/github.schema.graphql" - schemaFile, err := ioutil.ReadFile(inputFileName) + schemaFile, err := os.ReadFile(inputFileName) if err != nil { b.Fatal(err) } diff --git a/v2/pkg/astprinter/astprinter_test.go b/v2/pkg/astprinter/astprinter_test.go index b909b9cf2..0502f328a 100644 --- a/v2/pkg/astprinter/astprinter_test.go +++ b/v2/pkg/astprinter/astprinter_test.go @@ -2,7 +2,7 @@ package astprinter import ( "bytes" - "io/ioutil" + "os" "testing" "github.com/jensneuse/diffview" @@ -533,7 +533,7 @@ func TestPrintSchemaDefinition(t *testing.T) { goldie.Assert(t, "starwars_schema_definition", out) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/starwars_schema_definition.golden") + fixture, err := os.ReadFile("./fixtures/starwars_schema_definition.golden") if err != nil { t.Fatal(err) } @@ -557,7 +557,7 @@ func TestPrintOperationDefinition(t *testing.T) { goldie.Assert(t, "introspectionquery", out) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/introspectionquery.golden") + fixture, err := os.ReadFile("./fixtures/introspectionquery.golden") if err != nil { t.Fatal(err) } diff --git a/v2/pkg/asttransform/baseschema_test.go b/v2/pkg/asttransform/baseschema_test.go index e9b63860d..ccdcc2f9f 100644 --- a/v2/pkg/asttransform/baseschema_test.go +++ b/v2/pkg/asttransform/baseschema_test.go @@ -2,7 +2,7 @@ package asttransform_test import ( "bytes" - "io/ioutil" + "os" "testing" "github.com/jensneuse/diffview" @@ -28,7 +28,7 @@ func runTestMerge(definition, fixtureName string) func(t *testing.T) { got := buf.Bytes() goldie.Assert(t, fixtureName, got) if t.Failed() { - want, err := ioutil.ReadFile("./fixtures/" + fixtureName + ".golden") + want, err := os.ReadFile("./fixtures/" + fixtureName + ".golden") if err != nil { panic(err) } diff --git a/v2/pkg/astvalidation/reference/main.go b/v2/pkg/astvalidation/reference/main.go index f07359b80..0580ccd66 100644 --- a/v2/pkg/astvalidation/reference/main.go +++ b/v2/pkg/astvalidation/reference/main.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -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 { @@ -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") @@ -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) } diff --git a/v2/pkg/astvalidation/reference/testsgo/harness_test.go b/v2/pkg/astvalidation/reference/testsgo/harness_test.go index 57c2389e5..f1b5a3d7f 100644 --- a/v2/pkg/astvalidation/reference/testsgo/harness_test.go +++ b/v2/pkg/astvalidation/reference/testsgo/harness_test.go @@ -1,7 +1,7 @@ package testsgo import ( - "io/ioutil" + "os" "testing" "github.com/stretchr/testify/assert" @@ -314,7 +314,7 @@ func hasReportError(t *testing.T, report operationreport.Report) MessageCompare var testSchema string func init() { - content, err := ioutil.ReadFile("test_schema.graphql") + content, err := os.ReadFile("test_schema.graphql") if err != nil { panic(err) } diff --git a/v2/pkg/astvisitor/visitor_test.go b/v2/pkg/astvisitor/visitor_test.go index 910301f5a..976ebd6d6 100644 --- a/v2/pkg/astvisitor/visitor_test.go +++ b/v2/pkg/astvisitor/visitor_test.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" "io" - "io/ioutil" + "os" "testing" "github.com/jensneuse/diffview" @@ -46,7 +46,7 @@ func TestVisitOperation(t *testing.T) { if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/visitor.golden") + fixture, err := os.ReadFile("./fixtures/visitor.golden") if err != nil { t.Fatal(err) } @@ -125,7 +125,7 @@ func TestVisitSchemaDefinition(t *testing.T) { if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/schema_visitor.golden") + fixture, err := os.ReadFile("./fixtures/schema_visitor.golden") if err != nil { t.Fatal(err) } @@ -185,7 +185,7 @@ func TestWalker_Path(t *testing.T) { if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/path.golden") + fixture, err := os.ReadFile("./fixtures/path.golden") if err != nil { t.Fatal(err) } @@ -248,7 +248,7 @@ func TestVisitWithSkip(t *testing.T) { if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/visitor_skip.golden") + fixture, err := os.ReadFile("./fixtures/visitor_skip.golden") if err != nil { t.Fatal(err) } diff --git a/v2/pkg/codegen/codegen_test.go b/v2/pkg/codegen/codegen_test.go index 9d6764a31..bcf8d8c2c 100644 --- a/v2/pkg/codegen/codegen_test.go +++ b/v2/pkg/codegen/codegen_test.go @@ -2,7 +2,7 @@ package codegen import ( "bytes" - "io/ioutil" + "os" "testing" "github.com/stretchr/testify/assert" @@ -94,7 +94,7 @@ func TestCodeGen_GenerateDirectiveDefinitionStruct(t *testing.T) { goldie.Assert(t, "DataSource", data) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/DataSource.golden") + fixture, err := os.ReadFile("./fixtures/DataSource.golden") if err != nil { t.Fatal(err) } diff --git a/v2/pkg/graphql/execution_engine_v2.go b/v2/pkg/graphql/execution_engine_v2.go index e727ebc21..4ebe2ad38 100644 --- a/v2/pkg/graphql/execution_engine_v2.go +++ b/v2/pkg/graphql/execution_engine_v2.go @@ -6,7 +6,7 @@ import ( "compress/gzip" "context" "errors" - "io/ioutil" + "io" "net/http" "strconv" "sync" @@ -96,7 +96,7 @@ func (e *EngineResultWriter) AsHTTPResponse(status int, headers http.Header) *ht } res := &http.Response{} - res.Body = ioutil.NopCloser(b) + res.Body = io.NopCloser(b) res.Header = headers res.StatusCode = status res.ContentLength = int64(b.Len()) diff --git a/v2/pkg/graphql/execution_engine_v2_helpers_test.go b/v2/pkg/graphql/execution_engine_v2_helpers_test.go index e92f6969c..8539e2187 100644 --- a/v2/pkg/graphql/execution_engine_v2_helpers_test.go +++ b/v2/pkg/graphql/execution_engine_v2_helpers_test.go @@ -3,7 +3,7 @@ package graphql import ( "bytes" "encoding/json" - "io/ioutil" + "io" "net/http" "testing" @@ -34,14 +34,14 @@ func createTestRoundTripper(t *testing.T, testCase roundTripperTestCase) testRou var receivedBodyBytes []byte if req.Body != nil { var err error - receivedBodyBytes, err = ioutil.ReadAll(req.Body) + receivedBodyBytes, err = io.ReadAll(req.Body) require.NoError(t, err) } require.Equal(t, testCase.expectedBody, string(receivedBodyBytes), "roundTripperTestCase body do not match") } body := bytes.NewBuffer([]byte(testCase.sendResponseBody)) - return &http.Response{StatusCode: testCase.sendStatusCode, Body: ioutil.NopCloser(body)} + return &http.Response{StatusCode: testCase.sendStatusCode, Body: io.NopCloser(body)} } } diff --git a/v2/pkg/graphql/execution_engine_v2_test.go b/v2/pkg/graphql/execution_engine_v2_test.go index e27467345..17b5d5a91 100644 --- a/v2/pkg/graphql/execution_engine_v2_test.go +++ b/v2/pkg/graphql/execution_engine_v2_test.go @@ -6,7 +6,7 @@ import ( "compress/gzip" "context" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "sync" @@ -44,7 +44,7 @@ func TestEngineResponseWriter_AsHTTPResponse(t *testing.T) { headers := make(http.Header) headers.Set("Content-Type", "application/json") response := rw.AsHTTPResponse(http.StatusOK, headers) - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) require.NoError(t, err) assert.Equal(t, http.StatusOK, response.StatusCode) @@ -71,7 +71,7 @@ func TestEngineResponseWriter_AsHTTPResponse(t *testing.T) { reader, err := gzip.NewReader(response.Body) require.NoError(t, err) - body, err := ioutil.ReadAll(reader) + body, err := io.ReadAll(reader) require.NoError(t, err) assert.Equal(t, `{"key": "value"}`, string(body)) @@ -86,7 +86,7 @@ func TestEngineResponseWriter_AsHTTPResponse(t *testing.T) { assert.Equal(t, "deflate", response.Header.Get(httpclient.ContentEncodingHeader)) reader := flate.NewReader(response.Body) - body, err := ioutil.ReadAll(reader) + body, err := io.ReadAll(reader) require.NoError(t, err) assert.Equal(t, `{"key": "value"}`, string(body)) diff --git a/v2/pkg/graphql/request.go b/v2/pkg/graphql/request.go index c834fe9b9..cf9c2cbb3 100644 --- a/v2/pkg/graphql/request.go +++ b/v2/pkg/graphql/request.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "io" - "io/ioutil" "net/http" "github.com/wundergraph/graphql-go-tools/v2/pkg/ast" @@ -47,7 +46,7 @@ type Request struct { } func UnmarshalRequest(reader io.Reader, request *Request) error { - requestBytes, err := ioutil.ReadAll(reader) + requestBytes, err := io.ReadAll(reader) if err != nil { return err } diff --git a/v2/pkg/graphql/schema.go b/v2/pkg/graphql/schema.go index ee897acd5..0992daee5 100644 --- a/v2/pkg/graphql/schema.go +++ b/v2/pkg/graphql/schema.go @@ -3,7 +3,6 @@ package graphql import ( "bytes" "io" - "io/ioutil" "strings" "github.com/wundergraph/graphql-go-tools/v2/pkg/ast" @@ -59,7 +58,7 @@ func (s *Schema) calcHash() error { } func NewSchemaFromReader(reader io.Reader) (*Schema, error) { - schemaContent, err := ioutil.ReadAll(reader) + schemaContent, err := io.ReadAll(reader) if err != nil { return nil, err } diff --git a/v2/pkg/imports/graphql_file_test.go b/v2/pkg/imports/graphql_file_test.go index 394b01023..a92b825c3 100644 --- a/v2/pkg/imports/graphql_file_test.go +++ b/v2/pkg/imports/graphql_file_test.go @@ -2,7 +2,7 @@ package imports import ( "bytes" - "io/ioutil" + "os" "testing" "github.com/jensneuse/diffview" @@ -27,7 +27,7 @@ func TestGraphQLFile_Render(t *testing.T) { goldie.Assert(t, "render_result", dump, true) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/render_result.golden") + fixture, err := os.ReadFile("./fixtures/render_result.golden") if err != nil { t.Fatal(err) } diff --git a/v2/pkg/imports/imports.go b/v2/pkg/imports/imports.go index d3f0a1f40..4f513c351 100644 --- a/v2/pkg/imports/imports.go +++ b/v2/pkg/imports/imports.go @@ -3,7 +3,6 @@ package imports import ( "fmt" - "io/ioutil" "os" "path/filepath" "regexp" @@ -57,7 +56,7 @@ func (s *Scanner) scanFile(inputFilePath string) (*GraphQLFile, error) { fileDir := filepath.Dir(relativeFilePath) - content, err := ioutil.ReadFile(inputFilePath) + content, err := os.ReadFile(inputFilePath) if err != nil { return nil, err } diff --git a/v2/pkg/imports/imports_test.go b/v2/pkg/imports/imports_test.go index 8a45274a9..30b7d524e 100644 --- a/v2/pkg/imports/imports_test.go +++ b/v2/pkg/imports/imports_test.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "testing" @@ -29,7 +29,7 @@ func TestScanner(t *testing.T) { goldie.Assert(t, "scanner_result", dump, true) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/scanner_result.golden") + fixture, err := os.ReadFile("./fixtures/scanner_result.golden") if err != nil { t.Fatal(err) } @@ -52,7 +52,7 @@ func TestScanner_ScanRegex(t *testing.T) { goldie.Assert(t, "scanner_regex", dump, true) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/scanner_regex.golden") + fixture, err := os.ReadFile("./fixtures/scanner_regex.golden") if err != nil { t.Fatal(err) } @@ -68,7 +68,7 @@ func TestScanner_ScanRegex(t *testing.T) { goldie.Assert(t, "scanner_regex_render", buf.Bytes()) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/scanner_regex_render.golden") + fixture, err := os.ReadFile("./fixtures/scanner_regex_render.golden") if err != nil { t.Fatal(err) } diff --git a/v2/pkg/introspection/converter_test.go b/v2/pkg/introspection/converter_test.go index b683e2348..2756dbff7 100644 --- a/v2/pkg/introspection/converter_test.go +++ b/v2/pkg/introspection/converter_test.go @@ -3,7 +3,7 @@ package introspection import ( "bytes" "encoding/json" - "io/ioutil" + "os" "testing" "github.com/jensneuse/diffview" @@ -16,7 +16,7 @@ import ( ) func TestJSONConverter_GraphQLDocument(t *testing.T) { - starwarsSchemaBytes, err := ioutil.ReadFile("./fixtures/starwars.golden") + starwarsSchemaBytes, err := os.ReadFile("./fixtures/starwars.golden") require.NoError(t, err) definition, report := astparser.ParseGraphqlDocumentBytes(starwarsSchemaBytes) @@ -45,7 +45,7 @@ func TestJSONConverter_GraphQLDocument(t *testing.T) { schemaOutputPretty := outWriter.Bytes() // fmt.Println(string(schemaOutputPretty)) - // ioutil.WriteFile("./fixtures/starwars_generated.graphql", schemaOutputPretty, os.ModePerm) + // os.WriteFile("./fixtures/starwars_generated.graphql", schemaOutputPretty, os.ModePerm) // Ensure that recreated sdl is valid definition, report = astparser.ParseGraphqlDocumentBytes(schemaOutputPretty) @@ -56,7 +56,7 @@ func TestJSONConverter_GraphQLDocument(t *testing.T) { // Check that recreated sdl is the same as original goldie.Assert(t, "starwars", schemaOutputPretty) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/starwars.golden") + fixture, err := os.ReadFile("./fixtures/starwars.golden") require.NoError(t, err) diffview.NewGoland().DiffViewBytes("startwars", fixture, schemaOutputPretty) @@ -64,7 +64,7 @@ func TestJSONConverter_GraphQLDocument(t *testing.T) { } func BenchmarkJsonConverter_GraphQLDocument(b *testing.B) { - introspectedBytes, err := ioutil.ReadFile("./testdata/swapi_introspection_response.json") + introspectedBytes, err := os.ReadFile("./testdata/swapi_introspection_response.json") require.NoError(b, err) b.ResetTimer() diff --git a/v2/pkg/introspection/generator_test.go b/v2/pkg/introspection/generator_test.go index 9a52f115a..40d951c82 100644 --- a/v2/pkg/introspection/generator_test.go +++ b/v2/pkg/introspection/generator_test.go @@ -2,7 +2,7 @@ package introspection import ( "encoding/json" - "io/ioutil" + "os" "testing" "github.com/jensneuse/diffview" @@ -14,7 +14,7 @@ import ( func TestGenerator_Generate(t *testing.T) { t.Skip("FIXME") - starwarsSchemaBytes, err := ioutil.ReadFile("./testdata/starwars.schema.graphql") + starwarsSchemaBytes, err := os.ReadFile("./testdata/starwars.schema.graphql") if err != nil { panic(err) } @@ -38,7 +38,7 @@ func TestGenerator_Generate(t *testing.T) { goldie.Assert(t, "starwars_introspected", outputPretty) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/starwars_introspected.golden") + fixture, err := os.ReadFile("./fixtures/starwars_introspected.golden") if err != nil { t.Fatal(err) } @@ -50,7 +50,7 @@ func TestGenerator_Generate(t *testing.T) { func TestGenerator_Generate_Interfaces_Implementing_Interfaces(t *testing.T) { t.Skip("FIXME") - interfacesSchemaBytes, err := ioutil.ReadFile("./testdata/interfaces_implementing_interfaces.graphql") + interfacesSchemaBytes, err := os.ReadFile("./testdata/interfaces_implementing_interfaces.graphql") if err != nil { panic(err) } @@ -74,7 +74,7 @@ func TestGenerator_Generate_Interfaces_Implementing_Interfaces(t *testing.T) { goldie.Assert(t, "interfaces_implementing_interfaces", outputPretty) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/interfaces_implementing_interfaces.golden") + fixture, err := os.ReadFile("./fixtures/interfaces_implementing_interfaces.golden") if err != nil { t.Fatal(err) } diff --git a/v2/pkg/introspection/introspection_test.go b/v2/pkg/introspection/introspection_test.go index 3f87e63d6..5754cb6f7 100644 --- a/v2/pkg/introspection/introspection_test.go +++ b/v2/pkg/introspection/introspection_test.go @@ -2,13 +2,12 @@ package introspection import ( "encoding/json" - "io/ioutil" "os" "testing" ) func TestIntrospectionSerialization(t *testing.T) { - inputData, err := ioutil.ReadFile("./testdata/swapi_introspection_response.json") + inputData, err := os.ReadFile("./testdata/swapi_introspection_response.json") if err != nil { panic(err) } @@ -25,7 +24,7 @@ func TestIntrospectionSerialization(t *testing.T) { panic(err) } - err = ioutil.WriteFile("./testdata/out_swapi_introspection_response.json", outputData, os.ModePerm) + err = os.WriteFile("./testdata/out_swapi_introspection_response.json", outputData, os.ModePerm) if err != nil { panic(err) } diff --git a/v2/pkg/lexer/lexer_test.go b/v2/pkg/lexer/lexer_test.go index 388e07e0a..427db2b8d 100644 --- a/v2/pkg/lexer/lexer_test.go +++ b/v2/pkg/lexer/lexer_test.go @@ -3,7 +3,7 @@ package lexer import ( "encoding/json" "fmt" - "io/ioutil" + "os" "testing" "github.com/jensneuse/diffview" @@ -646,7 +646,7 @@ func TestLexerRegressions(t *testing.T) { goldie.Assert(t, "introspection_lexed", data) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/introspection_lexed.golden") + fixture, err := os.ReadFile("./fixtures/introspection_lexed.golden") if err != nil { t.Fatal(err) } diff --git a/v2/pkg/playground/playground_test.go b/v2/pkg/playground/playground_test.go index ddb5bc99e..82e436b9d 100644 --- a/v2/pkg/playground/playground_test.go +++ b/v2/pkg/playground/playground_test.go @@ -2,7 +2,7 @@ package playground import ( "bytes" - "io/ioutil" + "os" "testing" "github.com/davecgh/go-spew/spew" @@ -56,7 +56,7 @@ func TestConfigureHandlers(t *testing.T) { goldie.Assert(t, "handlers", out.Bytes()) if t.Failed() { - fixture, err := ioutil.ReadFile("./fixtures/handlers.golden") + fixture, err := os.ReadFile("./fixtures/handlers.golden") if err != nil { t.Fatal(err) } diff --git a/v2/pkg/starwars/starwars.go b/v2/pkg/starwars/starwars.go index 7148ede2a..c38c7b3c3 100644 --- a/v2/pkg/starwars/starwars.go +++ b/v2/pkg/starwars/starwars.go @@ -2,7 +2,7 @@ package starwars import ( "encoding/json" - "io/ioutil" + "os" "path" "github.com/stretchr/testify/require" @@ -57,13 +57,13 @@ func SetRelativePathToStarWarsPackage(path string) { } func Schema(t TestingTB) []byte { - schema, err := ioutil.ReadFile(path.Join(testdataPath, "testdata/star_wars.graphql")) + schema, err := os.ReadFile(path.Join(testdataPath, "testdata/star_wars.graphql")) require.NoError(t, err) return schema } func LoadQuery(t TestingTB, fileName string, variables QueryVariables) []byte { - query, err := ioutil.ReadFile(path.Join(testdataPath, fileName)) + query, err := os.ReadFile(path.Join(testdataPath, fileName)) require.NoError(t, err) return RequestBody(t, string(query), variables) diff --git a/v2/pkg/testing/federationtesting/gateway/datasource_poller.go b/v2/pkg/testing/federationtesting/gateway/datasource_poller.go index 52221dab5..74469907b 100644 --- a/v2/pkg/testing/federationtesting/gateway/datasource_poller.go +++ b/v2/pkg/testing/federationtesting/gateway/datasource_poller.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "net/http" "strings" @@ -196,7 +196,7 @@ func (d *DatasourcePollerPoller) fetchServiceSDL(ctx context.Context, serviceURL Errors GQLErr `json:"errors,omitempty"` } - bs, err := ioutil.ReadAll(resp.Body) + bs, err := io.ReadAll(resp.Body) if err != nil { return "", fmt.Errorf("read bytes: %v", err) } diff --git a/v2/pkg/testing/federationtesting/graphql_client_test.go b/v2/pkg/testing/federationtesting/graphql_client_test.go index 8369c41a2..0da21b49a 100644 --- a/v2/pkg/testing/federationtesting/graphql_client_test.go +++ b/v2/pkg/testing/federationtesting/graphql_client_test.go @@ -4,9 +4,10 @@ import ( "bytes" "context" "encoding/json" - "io/ioutil" + "io" "net" "net/http" + "os" "testing" "github.com/gobwas/ws" @@ -41,7 +42,7 @@ func requestBody(t *testing.T, query string, variables queryVariables) []byte { } func loadQuery(t *testing.T, filePath string, variables queryVariables) []byte { - query, err := ioutil.ReadFile(filePath) + query, err := os.ReadFile(filePath) require.NoError(t, err) return requestBody(t, string(query), variables) @@ -64,7 +65,7 @@ func (g *GraphqlClient) Query(ctx context.Context, addr, queryFilePath string, v req = req.WithContext(ctx) resp, err := g.httpClient.Do(req) require.NoError(t, err) - responseBodyBytes, err := ioutil.ReadAll(resp.Body) + responseBodyBytes, err := io.ReadAll(resp.Body) require.NoError(t, err) assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Contains(t, resp.Header.Get("Content-Type"), "application/json") diff --git a/v2/pkg/testing/federationtesting/util.go b/v2/pkg/testing/federationtesting/util.go index 2ac34750b..e565a5a95 100644 --- a/v2/pkg/testing/federationtesting/util.go +++ b/v2/pkg/testing/federationtesting/util.go @@ -1,7 +1,6 @@ package federationtesting import ( - "io/ioutil" "os" "path/filepath" "strings" @@ -45,5 +44,5 @@ func LoadTestingSubgraphSDL(upstream Upstream) ([]byte, error) { } absolutePath := filepath.Join(strings.Split(wd, "pkg")[0], federationTestingDirectoryRelativePath, string(upstream), "graph", "schema.graphqls") - return ioutil.ReadFile(absolutePath) + return os.ReadFile(absolutePath) } diff --git a/v2/pkg/testing/subscriptiontesting/util.go b/v2/pkg/testing/subscriptiontesting/util.go index 889eab196..a648ee0d0 100644 --- a/v2/pkg/testing/subscriptiontesting/util.go +++ b/v2/pkg/testing/subscriptiontesting/util.go @@ -2,7 +2,6 @@ package subscriptiontesting import ( "encoding/json" - "io/ioutil" "os" "path/filepath" "strings" @@ -63,7 +62,7 @@ func LoadSchemaFromExamplesDirectoryWithinPkg() ([]byte, error) { } absolutePath := filepath.Join(strings.Split(wd, "pkg")[0], chatExampleDirectoryRelativePath, "schema.graphql") - return ioutil.ReadFile(absolutePath) + return os.ReadFile(absolutePath) } func GraphQLRequestForOperation(operation string) ([]byte, error) {