简体   繁体   English

交叉编译:“用户:目前未在linux / amd64上实现”

[英]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.

相关问题 “用户:当前未在linux / amd64上实现”在fedora上带有新鲜的golang - “user: Current not implemented on linux/amd64” with fresh golang on fedora 用户:当前未在docker上使用golang在linux / amd64上实现 - user: Current not implemented on linux/amd64 with golang using docker scratch 如何使用 cgo 从 linux/amd64 交叉编译到 darwin/arm64? - How to cross-compile from linux/amd64 to darwin/arm64 with cgo? 进行交叉编译时出错:不支持的GOOS / GOARCH对linux / amd64 - Error with go cross-compilation: unsupported GOOS/GOARCH pair linux /amd64 CGO:使用 cgo_enabled = 1 从 mac/windows 交叉编译到 linux amd64 - CGO: Cross compile from mac/windows to linux amd64 with cgo_enabled = 1 os/user:为 linux/amd64 构建带有 osusergo 标签的“GroupIds 需要 cgo” - os/user: “GroupIds requires cgo” when building for linux/amd64 with tag osusergo 从Ubuntu amd64到arm7l进行交叉编译:exec用户进程导致“ exec格式错误” - Go Cross Compilation from Ubuntu amd64 to arm7l : exec user process caused “exec format error” 如何使用 golang docker 容器构建 linux/amd64 golang 可执行文件? - How to build linux/amd64 golang executable with golang docker container? 在amd64上拆分堆栈是不必要的 - Split stacks unneccesary on amd64 交叉编译在Windows 64(TDM-GCC-64)上转到.linux文件,但是尽管GOOS = linux,仍继续编译到.exe文件 - Cross-compiling Go on Windows 64 (TDM-GCC-64) to .linux file, but keeps compiling to .exe file despite GOOS=linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM