I have two proto files in the same folder.
Because of the history, a.proto's package name is different from b.proto. But they have a same message variable. Meanwhile, we can not change the defination because if we do this, there are too many files we need to change.
Firstly, the a.proto
package service_interface;
option go_package = "pb_gen/service";
message point {
required uint32 x = 1;
required uint32 y = 2;
}
message view {
required uint32 x = 1;
required uint32 y = 2;
}
then b.proto
import "a.proto";
package mydemo;
option go_package = "pb_gen/mydemo";
message point {
required uint32 x = 1;
required uint32 y = 2;
}
message bible {
required service_interface.view v = 1;
}
And I run the command to generate the pb.go files, no errors. But when I import these two protos into my golang files,
import (
"my/demo-api/pb_gen/mydemo"
)
it tells me
package pb_gen/mydemo is not in GOROOT
I have set go.mod, looks like
module my/demo-api
What is the problem? Or is there a better way to manage these two proto files?