How compile *.proto files?

I try compile Bitcoin lightningnetwork library with depended code. I have error: “lnrpc\rpc.pb.go:93:8: no buildable Go source files in d:\code\go\src\github.com\grpc-ecosystem\grpc-gateway\third_party\googleapis\google\api” m there are files: annotations.proto and http.proto,
annotations.proto begin with:

syntax = “proto3”;
package google.api;
import “google/api/http.proto”;
import “google/protobuf/descriptor.proto”;

I have downloaded file protoc.exe. But when I try >protoc --go_out=. *.proto I have errors:
google/api/http.proto: File not found.
google/protobuf/descriptor.proto: File not found.
annotations.proto: Import “google/api/http.proto” was not found or had errors.
annotations.proto: Import “google/protobuf/descriptor.proto” was not found or had errors.
annotations.proto:28:8: “google.protobuf.MethodOptions” is not defined.

http.proto is in current directory, no file descriptor.proto

I think you should file a bug on the repository, as they should include the generated serialization code in the package so you don’t have to compile the protobuf files yourself.

Doing so is surprisingly messy (in getting the various include paths right) so I’m not able to give you any specific advice.

In README:

Installation

First you need to install ProtocolBuffers 3.0.0-beta-3 or later.

mkdir tmp
cd tmp
git clone https://github.com/google/protobuf
cd protobuf
./autogen.sh
./configure
make
make check
sudo make install

Then, go get -u as usual the following packages:

go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go

I try compiling on Windows, download protoc.exe and do "go get -u " without errors but still are problems with *.proto, I issued.

If you are on Windows, rather download the protoc binary instead of trying to build the binary from source.

The latest protoc Windows binary: Click to download

Or visit the Release page

Remember to add the folder where protoc binary is to your %PATH%

Yes, I have downloaded binary, when I do “go get -u github.com…” I only make protoc-gen-go.exe, protoc-gen-swagger.exe and protoc-gen-grpc-gateway.exe but not solve problem with proto

Make sure you include the path of the third party library/annotations you are referencing

For example:

protoc -I/usr/local/include -I. \ -I$GOPATH/src \ -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ --go_out=plugins=grpc:. \ path/to/your_service.proto

Also, have a look at the steps on the grpc-gateway page (Step 3 +4) :

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.