关于交叉编译的错误: no buildable Go source files in $GOPATH/src/github.com/zeromq/goczmq

H,all

最近在研究分布式消息队列zeroMQ,goczmq是用go实现zeroMQ接口,我用goczmq写了个程序:

req_msg.go


package main

import (
"flag"
"log"

"github.com/zeromq/goczmq"
)

var (
client = flag.String("s", "sewise", "sign of client")
machine = flag.String("ma", "machine1", "sign of machine")
msg = flag.String("m", "hello world", "message")
count = flag.Int("c", 10, "send message count")
reqAddr = flag.String("req", "tcp://127.0.0.1:5556", "request address")
)

func main() {
flag.Parse()
reqEndpoint := *reqAddr
reqSock := goczmq.NewSock(goczmq.Req)
defer reqSock.Destroy()
err := reqSock.Connect(reqEndpoint)
if err != nil {
log.Fatal("connect error:", err)
}
log.Println("connect to ", reqEndpoint)

for i := 0; i < *count; i++ {
message := [][]byte{[]byte(*client), []byte(*machine), []byte(*msg)}
err := reqSock.SendMessage(message)
if err != nil {
panic(err)
}
m, err := reqSock.RecvMessage()
if err != nil {
panic(err)
}
// log.Println("response msg: ", string(*msg))
for _, v := range m {
log.Println("response msg: ", string(v))
}

// time.Sleep(time.Second)
}
}

我的golang版本:go version go1.7.1 darwin/amd64,系统:mac os
我执行 go build -o req req_msg.go 没有任何问题
但是我想交叉编译的时候:GOOS=linux go build -o req req_msg.go
就出现问题了:
go build github.com/zeromq/goczmq: no buildable Go source files in /Users/bao/go/src/github.com/zeromq/goczmq
这是为何??

已邀请:

sheepbao - 爱go,爱编程,专注网络开发,流媒体、分布式、网络加速,欢迎讨论listomebao@gmail.com

赞同来自: mintzhao

已经找到原因,需要用到cgo交叉编译的时候,要手动启动cgo,具体参考blog

mintzhao - 区块链开发者

赞同来自:

这句话的意思是,在/Users/bao/go/src/github.com/zeromq/goczmq下面没有go文件,没有文件怎么编译呢?

要回复问题请先登录注册