0
votes

I have a city.proto file where I import a well-known third-party package called gogoproto. I created gRPC server and now I want to test it's rpc methods by evans gRPC client.

I used such command but it raise an error:

evans proto/city.proto --host localhost --port 8000

Error:

evans: failed to run REPL mode: failed to instantiate a new spec: failed to instantiate the spec from proto files: proto: failed to parse passed proto files: proto/city.proto:7:8: open github.com/gogo/p rotobuf/gogoproto/gogo.proto: The system cannot find the path specified.

city.proto:

syntax = "proto3";

package proto;

import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";

option go_package = "./proto";

message City {
    uint64 id = 1 [
        json_name = "id",
        (gogoproto.jsontag) = "id"
    ];
    google.protobuf.Timestamp foundation_date = 2 [
        json_name = "foundation_date",
        (gogoproto.jsontag) = "foundation_date",
        (gogoproto.nullable) = false,
        (gogoproto.stdtime) = true
    ];
    google.protobuf.StringValue name = 3 [
        json_name = "name",
        (gogoproto.jsontag) = "name",
        (gogoproto.wktpointer) = true
    ];
    google.protobuf.StringValue country = 4 [
        json_name = "country",
        (gogoproto.jsontag) = "country",
        (gogoproto.wktpointer) = true
    ];
}

***

go version:

go version go1.12.9 windows/amd64

protoc version:

libprotoc 3.11.4

evans version:

0.9.0

In all probability, I am not correctly trying to start REPL mode. I assume that the command needs to specify the path to the directory where third-party proto files are located. I am confused. How start evans (gRPC client) correctly?

1

1 Answers

0
votes

To run Evans correctly, it's required to specify the correct paths to search for imports by using --path. It is almost similar to --proto_path in protoc. For example, we assume that github.com/gogo/protobuf is located in /path/to/github.com/gogo/protobuf:

$ evans --path /path/to --path . proto/city.proto
$ evans --path /path/to --path . --proto proto/city.proto # Better

Note that --path . is also required to search proto/city.proto.

Well-known protos managed by Google such as google/protobuf/wrappers.proto and google/protobuf/timestamp.proto are loaded by default, but in other cases, we have to specify correct paths to use third-party protos.