[英]Cross compiling: “user: Current not implemented on linux/amd64”
I compile the following Go program on a linux/amd64 box: 我在linux / amd64盒子上编译了以下Go程序:
package main
import (
"fmt"
"os/user"
)
func main() {
fmt.Println(user.Current())
}
This works fine. 这很好用。 But when I cross compile it from a Mac box, I get the following error when I run that program on my linux box:
但是当我从Mac框交叉编译它时,我在我的linux盒子上运行该程序时出现以下错误:
user: Current not implemented on linux/amd64
How can I cross compile and use the Current function in package os/user
? 如何交叉编译并使用包
os/user
的Current函数?
Edit 1: I should add that these are the instructions I've used to setup cross compiling on my Mac box: https://code.google.com/p/go-wiki/wiki/WindowsCrossCompiling 编辑1:我应该补充一点,这些是我用来在Mac机上设置交叉编译的说明: https : //code.google.com/p/go-wiki/wiki/WindowsCrossCompiling
Edit 2: cross compiling for windows/386 works fine. 编辑2:交叉编译windows / 386工作正常。
This is due to Issue 6376: user.Current panic in darwin-amd64 when crosscompiled from linux-amd64 : 这是由于问题6376:从linux-amd64交叉编译时darwin-amd64中的user.Current恐慌 :
os/user relies on cgo, and cgo is disabled for cross compiling, thus this is expected.
os / user依赖于cgo,并且cgo被禁用以进行交叉编译,因此这是预期的。
if you use os/user, you must compile natively on OS X.
如果使用os / user,则必须在OS X上进行本机编译。
even if we enable cross compilation cgo support, I doubt everybody have a working OS X cross toolchain on their linux machine.
即使我们启用交叉编译cgo支持,我怀疑每个人在他们的linux机器上都有一个工作的OS X交叉工具链。
Status: WorkingAsIntended
状态:WorkingAsIntended
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.