I am compiling an open source project written in go (openblockchain). I get the following error when I do go build
. Can anyone help me with this issue
Compilation Error
> go build
../go/src/github.com/openblockchain/obc-peer/openchain/util/utils.go:28:2: cannot find package "google/protobuf" in any of:
/usr/src/pkg/google/protobuf (from $GOROOT)
/home/vichu/go/src/google/protobuf (from $GOPATH)
Additional Information
I referred the question here in Stack Overflow but still no luck in solving the issue. Here is some more information about what all I have:
Protoc version is up to date.
> protoc --version
libprotoc 3.0.0
My environment variables
> echo $GOPATH
/home/vichu/go
> echo $GOBIN
/home/vichu/go/bin
Protobuf has been built using the README.
~/go/src/github.com/golang/protobuf$ ls
AUTHORS CONTRIBUTORS jsonpb LICENSE Makefile Make.protobuf proto protoc-gen-go proto.pb.go ptypes README.md
Update
I did the following Util.go
in source code as mentioned in answer. The source code is open source and here is the link
- gp "google/protobuf"
+ gp "github.com/google/protobuf"
When I do go get
, the below is the error
> go get github.com/google/protobuf
can't load package: package github.com/google/protobuf: no buildable Go source files in /home/vichu/go/src/github.com/google/protobuf
Firstly, your import is wrong, you are trying to import a C++ package, not a golang package. It needs to be:
import ("github.com/golang/protobuf/proto")
If you don't have this package installed already, you need to run from command line:
go get github.com/golang/protobuf/proto
I think, at the end of your *.pb.go file you also do not have some thing like "gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00 ...."
The issue is we use a wrong compiler for generating.
So:
1) I reinstall protobuf from: https://github.com/google/protobuf/releases
2) Then (I'm using ubuntu and it has a proto compiler also): apt remove protobuf-compiler
Rebuild the *.proto file. It fixed the bug.