pcbook-go
pcbook-go copied to clipboard
protoc-gen-go failed :: The import path must contain at least one forward slash ('/') character."
protoc --version
libprotoc 3.15.6
make gen
protoc --proto_path=proto proto/*.proto --go_out=plugins=grpc:pb --grpc-gateway_out=:pb --openapiv2_out=:swagger
protoc-gen-go: invalid Go import path "." for "auth_service.proto"
The import path must contain at least one forward slash ('/') character.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
--go_out: protoc-gen-go: Plugin failed with status code 1.
make: *** [Makefile:2: gen] Error 1
I assume they made some changes for the newest protoc that now require you to set a import path with at least one "/" ?!
same issue!
same issue
same issue
➜ rpcEcomm protoc --version
libprotoc 3.6.1
I solved it, you need to fix the go_package inside the proto file
Initially, my .proto file was
syntax = "proto3";
package greet;
option go_package="greetpb";
service GreetService{}
I changed the value of go_package from "greetpb" to "./greet/greetpb" and it started working.
You need to change your option go_package into
option go_package = "./;pb";
The first param means relative path where the code you want to generate. The path relative to the --go_out , you set in your command.
you need set the path twice ,it is confused, I know....
The second is just the package name.
You need to change your
option go_packageintooption go_package = "./;pb";The first param means relative path where the code you want to generate. The path relative to the--go_out, you set in your command.you need set the path twice ,it is confused, I know....
The second is just the package name.
Saved my day!
You need to change your
option go_packageintooption go_package = "./;pb";The first param means relative path where the code you want to generate. The path relative to the--go_out, you set in your command. you need set the path twice ,it is confused, I know.... The second is just the package name.Saved my day!
Save two days ~!!!
You need to change your
option go_packageintooption go_package = "./;pb";The first param means relative path where the code you want to generate. The path relative to the--go_out, you set in your command.you need set the path twice ,it is confused, I know....
The second is just the package name.
That works,thank you
thanks
i dont even put my proto file inside some folder, is it has anything to do with folder if i user go_package =".folder/;pb"??
You need to change your
option go_packageintooption go_package = "./;pb";The first param means relative path where the code you want to generate. The path relative to the--go_out, you set in your command.you need set the path twice ,it is confused, I know....
The second is just the package name.
Thank you very much! Saved my day :)
Initially, my
.protofile wassyntax = "proto3"; package greet; option go_package="greetpb"; service GreetService{}I changed the value of
go_packagefrom"greetpb"to"./greet/greetpb"and it started working.
Awesome details there! Save me 1 day! Thank you!
protoc --proto_path=proto proto/*.proto --go_out=plugins=grpc:pb
good
Thank you guys, you help me a lot.
Thank you !!
I hacked proto-gen-go to fix this, and it works just fine:
- https://github.com/paralin/protobuf-go/commit/badd5ddf78097f5449793dfd620828df2d77a840
- https://github.com/paralin/protobuf-go/commit/a915b3bc160926e5c42e6ebd996d3b1719de2f38
I fixed it changing the go_package value from protofiles;pb to ./protofiles;pb
option go_package = "./protofiles;pb";
You need to change your
option go_packageintooption go_package = "./;pb";The first param means relative path where the code you want to generate. The path relative to the--go_out, you set in your command.you need set the path twice ,it is confused, I know....
The second is just the package name.
Thanks a lot, really saved me there!
I changed my go_package to
option go_package = "./;proto";
and this was the command I used (the folder name I used to store my proto file is proto)
protoc --proto_path=proto --go_out=proto --go_opt=paths=source_relative proto.proto
... it's way easier to just use a modified version of protoc-gen-go without the unnecessary check for a / in the package import path.
it works just fine without it.
see:
- https://github.com/aperturerobotics/protobuf-go/commit/349b2ae33224119ac0edc3ff180d0d21da89ac0c
- https://github.com/aperturerobotics/protobuf-go/commit/78b627edc1c2f87ee69208f3d067cd592936e299
- https://github.com/aperturerobotics/protobuf-go/commit/dcfbe19b6cd6ac17078f7bd3719bf7ff1a1c5f06
Hey guys, I recently made a video in my Backend Master Class course with the latest version of protoc, so this is no longer an issue. You can check it out here: [Backend #40] Define gRPC API and generate Go code with protobuf
Discuss with me & other students on Tech School Discord group
incase any one wants the generated file to be in same folder with .proto just use option go_package="../greetpb";