mirror of
https://github.com/fullstorydev/grpcurl.git
synced 2026-09-05 18:16:08 +03:00
Fix nil input stream panic under Go jsonv2
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -764,7 +765,7 @@ func main() {
|
|||||||
// create a request to invoke an RPC
|
// create a request to invoke an RPC
|
||||||
tmpl := grpcurl.MakeTemplate(dsc)
|
tmpl := grpcurl.MakeTemplate(dsc)
|
||||||
options := grpcurl.FormatOptions{EmitJSONDefaultFields: true}
|
options := grpcurl.FormatOptions{EmitJSONDefaultFields: true}
|
||||||
_, formatter, err := grpcurl.RequestParserAndFormatter(grpcurl.Format(*format), descSource, nil, options)
|
_, formatter, err := grpcurl.RequestParserAndFormatter(grpcurl.Format(*format), descSource, bytes.NewReader(nil), options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail(err, "Failed to construct formatter for %q", *format)
|
fail(err, "Failed to construct formatter for %q", *format)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ func TestHandler(t *testing.T) {
|
|||||||
|
|
||||||
verbose := verbosityLevel > 0
|
verbose := verbosityLevel > 0
|
||||||
|
|
||||||
_, formatter, err := RequestParserAndFormatter(format, source, nil, FormatOptions{IncludeTextSeparator: !verbose})
|
_, formatter, err := RequestParserAndFormatter(format, source, bytes.NewReader(nil), FormatOptions{IncludeTextSeparator: !verbose})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to create parser and formatter: %v", err)
|
t.Errorf("Failed to create parser and formatter: %v", err)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user