Skip to content
Closed
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
3 changes: 1 addition & 2 deletions internal/codegenerator/parse_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package codegenerator
import (
"fmt"
"io"
"io/ioutil"

"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/pluginpb"
)

// ParseRequest parses a code generator request from a proto Message.
func ParseRequest(r io.Reader) (*pluginpb.CodeGeneratorRequest, error) {
input, err := ioutil.ReadAll(r)
input, err := io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("failed to read code generator request: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/descriptor/grpc_api_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package descriptor
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"

"github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/apiconfig"
Expand Down Expand Up @@ -64,7 +64,7 @@ func registerHTTPRulesFromGrpcAPIService(registry *Registry, service *apiconfig.
// Note that for the purposes of the gateway generator we only consider a subset of all
// available features google supports in their service descriptions.
func (r *Registry) LoadGrpcAPIServiceFromYAML(yamlFile string) error {
yamlFileContents, err := ioutil.ReadFile(yamlFile)
yamlFileContents, err := os.ReadFile(yamlFile)
if err != nil {
return fmt.Errorf("failed to read gRPC API Configuration description from '%v': %v", yamlFile, err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/descriptor/openapi_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package descriptor
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"

"github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig"
"google.golang.org/protobuf/encoding/protojson"
Expand Down Expand Up @@ -51,7 +51,7 @@ func registerOpenAPIOptions(registry *Registry, openAPIConfig *openapiconfig.Ope
// and registers the OpenAPI options the given registry.
// This must be done after loading the proto file.
func (r *Registry) LoadOpenAPIConfigFromYAML(yamlFile string) error {
yamlFileContents, err := ioutil.ReadFile(yamlFile)
yamlFileContents, err := os.ReadFile(yamlFile)
if err != nil {
return fmt.Errorf("failed to read OpenAPI Configuration description from '%v': %v", yamlFile, err)
}
Expand Down
3 changes: 1 addition & 2 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"math"
"net/textproto"
"os"
Expand Down Expand Up @@ -2188,7 +2187,7 @@ func goTemplateComments(comment string, data interface{}, reg *descriptor.Regist
tpl, err := template.New("").Funcs(template.FuncMap{
// Allows importing documentation from a file
"import": func(name string) string {
file, err := ioutil.ReadFile(name)
file, err := os.ReadFile(name)
if err != nil {
return err.Error()
}
Expand Down
7 changes: 3 additions & 4 deletions runtime/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package runtime_test
import (
"context"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -104,7 +103,7 @@ func TestForwardResponseStream(t *testing.T) {
if h := w.Header.Get("Transfer-Encoding"); h != "chunked" {
t.Errorf("ForwardResponseStream missing header chunked")
}
body, err := ioutil.ReadAll(w.Body)
body, err := io.ReadAll(w.Body)
if err != nil {
t.Errorf("Failed to read response body with %v", err)
}
Expand Down Expand Up @@ -238,7 +237,7 @@ func TestForwardResponseStreamCustomMarshaler(t *testing.T) {
if h := w.Header.Get("Transfer-Encoding"); h != "chunked" {
t.Errorf("ForwardResponseStream missing header chunked")
}
body, err := ioutil.ReadAll(w.Body)
body, err := io.ReadAll(w.Body)
if err != nil {
t.Errorf("Failed to read response body with %v", err)
}
Expand Down Expand Up @@ -302,7 +301,7 @@ func TestForwardResponseMessage(t *testing.T) {
if h := w.Header.Get("Content-Type"); h != tt.contentType {
t.Errorf("Content-Type %v want %v", h, tt.contentType)
}
body, err := ioutil.ReadAll(w.Body)
body, err := io.ReadAll(w.Body)
if err != nil {
t.Errorf("Failed to read response body with %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions runtime/marshal_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"errors"
"io/ioutil"

"google.golang.org/protobuf/proto"
)
Expand Down Expand Up @@ -38,7 +37,7 @@ func (*ProtoMarshaller) Unmarshal(data []byte, value interface{}) error {
// NewDecoder returns a Decoder which reads proto stream from "reader".
func (marshaller *ProtoMarshaller) NewDecoder(reader io.Reader) Decoder {
return DecoderFunc(func(value interface{}) error {
buffer, err := ioutil.ReadAll(reader)
buffer, err := io.ReadAll(reader)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions utilities/readerfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package utilities
import (
"bytes"
"io"
"io/ioutil"
)

// IOReaderFactory takes in an io.Reader and returns a function that will allow you to create a new reader that begins
// at the start of the stream
func IOReaderFactory(r io.Reader) (func() io.Reader, error) {
b, err := ioutil.ReadAll(r)
b, err := io.ReadAll(r)
if err != nil {
return nil, err
}
Expand Down
Loading