I have installed protoc by brew install protobuf, the result is:
Allen@MacBook-Pro:~/workspace/golang/src/github.com/hxzqlh/protobuf/protobuf/examples$ brew search protobuf
protobuf ✔ protobuf-swift [email protected]
protobuf-c [email protected] [email protected]
homebrew/php/php53-protobuf homebrew/php/php55-protobuf
homebrew/php/php54-protobuf homebrew/php/php56-protobuf
Allen@MacBook-Pro:~/workspace/golang/src/github.com/hxzqlh/protobuf/protobuf/examples$ protoc --version
libprotoc 3.3.0
And I installed protobuf for go as the installation said:go get -u github.com/golang/protobuf/protoc-gen-go
then I checked out this protobuf example:https://github.com/google/protobuf/tree/master/examples to test wether protobuf is working:
$ make go
mkdir tutorial # make directory for go package
protoc --go_out=tutorial addressbook.proto
go build -o add_person_go add_person.go
# command-line-arguments
/usr/local/go/pkg/tool/darwin_amd64/link: cannot open file /usr/local/go/pkg/darwin_amd64/github.com/golang/protobuf/proto.a: open /usr/local/go/pkg/darwin_amd64/github.com/golang/protobuf/proto.a: no such file or directory
make: *** [add_person_go] Error 2
my env:
Allen@MacBook-Pro:~/workspace/golang/src/github.com/hxzqlh/protobuf/protobuf/examples$ go version
go version go1.8 darwin/amd64
Allen@MacBook-Pro:~/workspace/golang/src/github.com/hxzqlh/protobuf/protobuf/examples$ env
TERM_PROGRAM=iTerm.app
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/zv/5ym0ctp965d87czt9q8fkt580000gn/T/
GOBIN=/Users/Allen/workspace/golang/bin
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.kaOp8UQA7i/Render
TERM_PROGRAM_VERSION=3.0.15
OLDPWD=/Users/Allen/workspace/golang/src/github.com/hxzqlh/protobuf
TERM_SESSION_ID=w0t2p1:9ADD288A-7541-4F26-9E9C-C7D21C95CE3E
USER=Allen
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.mazza86P9o/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PATH=/Users/Allen/workspace/golang/bin:/usr/local/go/bin:/Users/Allen/workspace/golang/bin:/usr/local/go/bin:/Users/Allen/workspace/golang/bin:/usr/local/go/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin
PWD=/Users/Allen/workspace/golang/src/github.com/hxzqlh/protobuf/protobuf/examples
ITERM_PROFILE=Default
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/Allen
COLORFGBG=7;0
GOROOT=/usr/local/go
ITERM_SESSION_ID=w0t2p1:9ADD288A-7541-4F26-9E9C-C7D21C95CE3E
LOGNAME=Allen
LC_CTYPE=UTF-8
GOPATH=/Users/Allen/workspace/golang
_=/usr/bin/env
Can anybody help explain why golang says it cannot find protoc.a? In my opinion, I have set the GOPATH env variable, how can golang still try to search the protoc.a in /usr/local/go/pkg/darwin_amd64/github.com/golang/protobuf instead of ~/workspace/golang/pkg/darwin_amd64/github.com/golang/protobuf, In fact ,~/workspace/golang/pkg/darwin_amd64/github.com/golang/protobuf/protoc.a DO exsit.
Allen@MacBook-Pro:~/workspace/golang/pkg/darwin_amd64$ ls -l github.com/golang/protobuf/
total 1392
-rw-r--r-- 1 Allen staff 709986 May 22 17:27 proto.a
drwxr-xr-x 6 Allen staff 204 May 22 17:27 protoc-gen-go
To work around this problem, I have to do this at present:
Allen@MacBook-Pro:~/workspace/golang/pkg/darwin_amd64$ cp github.com/golang/protobuf/proto.a /usr/local/go/pkg/darwin_amd64/github.com/golang/protobuf/proto.a
I have the same issue
This seems more like a bug in the Makefile script in the primary protobuf repo where it is not forwarding the GOPATH variable.
I've also encountered this issue
please try :
rm -rf $GOPATH/pkg/darwin_amd64
Closing as this seems to be issues with a stale $GOPATH/pkg.
Most helpful comment
please try :
rm -rf $GOPATH/pkg/darwin_amd64