Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross compiling: "user: Current not implemented on linux/amd64"

I compile the following Go program on a linux/amd64 box:

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:

user: Current not implemented on linux/amd64

How can I cross compile and use the Current function in package os/user?


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


Edit 2: cross compiling for windows/386 works fine.

like image 606
topskip Avatar asked Dec 16 '13 11:12

topskip


1 Answers

This is due to Issue 6376: user.Current panic in darwin-amd64 when crosscompiled from linux-amd64:

os/user relies on cgo, and cgo is disabled for cross compiling, thus this is expected.

if you use os/user, you must compile natively on OS X.

even if we enable cross compilation cgo support, I doubt everybody have a working OS X cross toolchain on their linux machine.

Status: WorkingAsIntended

like image 95
Intermernet Avatar answered Oct 23 '22 04:10

Intermernet