I am using buf CLI to generate protos for Go via command buf generate
.
I am able to generate protos successfully if any imports are defined in the same directory.
However, I could not import protos from another repository or even the same repository but different folder.
Here is how I tried to import error.proto
from the same repository to service.proto
.
It might be a different repository as well.
syntax = "proto3";
option go_package = "github.com/organization/repository/service/proto/gen/service/v1;servicev1";
package service.v1;
import "github.com/organization/repository/common/proto/def/error/v1/error.proto";
This file relies inside directory:
service/proto/def/service/v1/service.proto
and my buf.gen.yaml
look like
version: v1
plugins:
- name: go
out: ../../
opt: module=github.com/organization/repository/service
- name: go-grpc
out: ../../
opt: require_unimplemented_servers=false,module=github.com/organization/repository/service
I call buf generate
in directory:
cd service/proto/def
buf generate
Error message is:
common/proto/def/error/v1/error.proto: does not exist
Is it possible to import that error.proto? If so, how can I do that?