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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With