5
votes

I followed the gRPC quickstart document in this link https://grpc.io/docs/languages/go/quickstart/ and while regenerating the gRPC code i am getting error ( Unknown flag: --go_opt) as shown below. Tried all the options but not working. It also gives ( Unknown flag: --go-grpc_opt) error.

Command -

$ protoc \
  --go_out=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config:. \
  --go-grpc_out=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config:. \
  --go-grpc_opt=paths=source_relative \
  helloworld/helloworld.proto

Error - Unknown flag: --go_opt
2
Instead of a screenshot, can you copy paste the command you run? It looks like you hit this issue: github.com/grpc/grpc.io/issues/298#issuecomment-656767393 You need to install protoc-gen-go-grpc in your PATHHalil Kaskavalci
I have already tried github.com/grpc/grpc.io/issues/298#issuecomment-656767393 as it is given in the mentioned link here grpc.io/docs/languages/go/quickstart. This is the command ( cd ../../cmd/protoc-gen-go-grpc && go install . )BlockchainGeek
can you verify if protoc-gen-go or protoc-gen-go-grpc binary is present in your PATH?Halil Kaskavalci
I can see protoc-gen-go-grpc folder under grpc-go/cmdBlockchainGeek

2 Answers

7
votes

I had a same issue. I removed the installed protobuf compiler and reinstalled protobuf compiler with "Install pre-compiled binaries" option in https://grpc.io/docs/protoc-installation/.

sudo apt-get remove protobuf-compiler
$PB_REL="https://github.com/protocolbuffers/protobuf/releases"
$ curl -LO $PB_REL/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip

$sudo apt install unzip
$unzip protoc-3.12.1-linux-x86_64.zip -d HOME/.local

$export PATH="$PATH:$HOME/.local/bin"
-4
votes

You are missing the 4th line: --go_opt=paths=source_relative \.