I am trying to work out the example from a gRPC book, and I struggle to get what's wrong with what I am doing.
I have a .proto file, and I can compile it into the .pb.go stub.
I am trying to build both the client and the server, and the folders structure looks as following:
I run these commands successfully and I generate the .pb.go files for both client and server, so no issue with that:
service % protoc -I ecommerce ecommerce/product_info.proto --go_out=plugins=grpc:./ecommerce
client % protoc -I ecommerce ecommerce/product_info.proto --go_out=plugins=grpc:./ecommerce
However, while the server's go file can resolve all the imports, the same doesn't happen for the client.
Looking at the folder structure, I was expecting everything to work out (I just started this week with go and gRPC, so please be understanding).
My IDE is GoLand, I suspect there is something wrong with the paths, but I wouldn't know where to start right now.
As per the comments the screenshot showed a go.mod
in service
but none in client
. As goland will be running with 'Go Modules Integration' enabled it will be expecting a module (I'd highly recommend using modules!).
The simplest fix is to run go mod init [module-path]
(followed by go mod tidy
) in the client folder. You could also establish a module in the backend
folder (or productinfo
folder) and that will be shared by child folders.