3

There is a directory

├── cmd │ └── main.go ├── go.mod └── proto └── forward.proto 

write in the terminal

protoc --go_out=. --go_opt=paths=source_relative \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \ proto/forward.proto 

I get the error

protoc-gen-go: invalid Go import path "forward" for "proto/forward.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. a.mamedov@a-mamedov forward-spinner %

How to fix it and generate grpc for forward.proto file?

4
  • 1
    Please check this SO answer that describes go_option you can use to generate proto code. Commented Aug 3, 2021 at 14:33
  • 1
    the error msg shows the error, please post your proto file, especially the import and option part Commented Aug 4, 2021 at 3:31
  • btw, this may help github.com/techschool/pcbook-go/issues/3#issuecomment-821860413 Commented Aug 4, 2021 at 3:35
  • Please show us your first lines of the proto file. Commented Aug 16, 2021 at 6:43

1 Answer 1

11

The problem lies on the .proto file, in line option go_package="forward";.

In order to compile the code just add ./ in front of the require file:

option go_package="./forward";

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.