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?

Denver Toha
  • 131
  • 1
  • 2
  • 1
    Please check this [SO answer](https://stackoverflow.com/questions/61666805/correct-format-of-protoc-go-package) that describes `go_option` you can use to generate proto code. – Oleg Butuzov Aug 03 '21 at 14:33
  • 1
    the error msg shows the error, please post your proto file, especially the import and option part – PapEr Aug 04 '21 at 03:31
  • btw, this may help https://github.com/techschool/pcbook-go/issues/3#issuecomment-821860413 – PapEr Aug 04 '21 at 03:35
  • Please show us your first lines of the proto file. – ttrasn Aug 16 '21 at 06:43

1 Answers1

9

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";

Yar
  • 7,020
  • 11
  • 49
  • 69