I have a proto file product.proto
and I want to use it in catalog.proto
. I can successfully import product.proto
in catalog.proto
but auto-generated catalog.pb.go
is not able to reconize the path of its dependency i.e. product.pb.go
. It states:
could not import catalog/pb/entities (cannot find package "catalog/pb/entities" in any of /usr/local/go/src/catalog/pb/entities (from $GOROOT)
/Users/trimulabs/go/src/catalog/pb/entities (from $GOPATH))
Directory structure
catalog
┣ main
┃ ┣ client.go
┃ ┗ server.go
┣ pb
┃ ┣ entities
┃ ┃ ┣ product.pb.go
┃ ┃ ┗ product.proto
┃ ┣ catalog.pb.go
┃ ┗ catalog.proto
catalog.proto
syntax = "proto3";
package catalog;
import "catalog/pb/entities/product.proto";
service CatalogService {
rpc PostProduct (PostProductRequest) returns (PostProductResponse) {}
rpc GetProduct (GetProductRequest) returns (GetProductResponse) {}
rpc GetProducts (GetProductsRequest) returns (GetProductsResponse) {}
}
product.proto
message Product {
string id = 1;
string name = 2;
string description = 3;
double price = 4;
}
message PostProductRequest {
string name = 1;
string description = 2;
double price = 3;
}
message PostProductResponse {
Product product = 1;
}
message GetProductRequest {
string id = 1;
}
message GetProductResponse {
Product product = 1;
}
message GetProductsRequest {
uint64 skip = 1;
uint64 take = 2;
repeated string ids = 3;
string query = 4;
}
message GetProductsResponse {
repeated Product products = 1;
}
Can anyone please help?