Inside city.proto
file I want to use (import) protobuf's .proto
files. In my golang application I use go modules.
city.proto:
syntax = "proto3";
package proto;
import "google/protobuf/timestamp.proto";
option go_package = "./proto";
message City {
google.protobuf.Timestamp create_at = 1;
}
When I try to generate code from city.proto
file it raise such error:
google/protobuf/timestamp.proto: File not found.
city.proto:3:1: Import "google/protobuf/timestamp.proto" was not found or had errors.
city.proto:25:5: "google.protobuf.Timestamp" is not defined.
I created a proto
folder in the directory of my gRPC project. The city.proto
file is located in this folder. I run such command:
protoc -I proto/ proto/city.proto --go_out=plugins=grpc:proto/city.
This command works only in cases when I don't use import in the proto file.
go version:
go version go1.12.9 windows/amd64
protoc --version:
libprotoc 3.11.4
echo %GOPATH%:
C:\Users\NNogerbek\go
Inside that directory I see three folders with such structure:
bin
protoc.exe
protoc-gen-go.exe
pkg
mod
**packages**
src
google.com
protobuf
timestamp.proto
I run such command:
go list -f "{{ .Path }} {{ .Dir }}" -m github.com/golang/protobuf
Command result:
github.com/golang/protobuf C:\Users\NNogerbek\go\pkg\mod\github.com\golang\protobuf@v1.4.0