Correct format of protoc go_package?

For pure proto generations you can do the following

protoc --go_out=paths=source_relative:./gen -I. authenticator.proto

or to generate for grpc the following can be used

protoc --go_out=plugins=grpc:./gen --go_opt=paths=source_relative authenticator.proto

If that fails you likely have a newer version of protoc and need to use the following command instead.

protoc --go-grpc_out=./gen --go-grpc_opt=paths=source_relative authenticator.proto

This is just Google making isolated decisions once again about how you should write and manage your code. However if you dig through enough issues of people having similar problems I found the above command can now be used. In addition to adding the full import path as shown in the other answer

option go_package = "github.com/example/path/gen;gen";

Following the above package and protoc command you would have your proto file in the project root with a module name of github.com/example/path. Your code would then be placed inside the gen folder which you will be responsible for creating.

You may need to adjust the output location of source_relative for your use but at least you don't end up with the duplication of paths or having to rely on placing your code in GOPATH again.

This may break going forward because of the additional changes found in this ticket. Unfortunately the binary name is exactly the same so if you run into issues read that ticket and try switching the version that you have installed until the new protoc-gen-go is ready for prod.


You just need to add a Go option which will tell to add file relative to proto file.

protoc --go_out=. --go_opt=paths=source_relative your_file.proto 

This will make the your_file.pb.go in same directory as your_file.proto