Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with go cross-compilation: unsupported GOOS/GOARCH pair linux /amd64

I'm trying to cross-compile go code on windows, targeting linux machine. I have used simple go code to determine target os/platform,

package main

import "fmt"
import "runtime"

func main() {
        fmt.Printf("OS: %s\nArchitecture: %s\n", runtime.GOOS, runtime.GOARCH)
}

Running above code gives me

OS: linux
Architecture: amd64

hovever when I try to cross compile on windows (using JetBrain's Goland IDE) with

> go version
go version go1.9.2 windows/amd64

using GOOS=linux ;GOARCH=amd64 environment flags, I get following error

cmd/go: unsupported GOOS/GOARCH pair linux /amd64

I am new to golang, so I might be missing something simple, but this error got me stuck. Any help appreciated...

like image 548
Bolek Tekielski Avatar asked Nov 30 '22 14:11

Bolek Tekielski


1 Answers

It looks like your GOOS is getting set to "linux ", not "linux".

like image 106
hobbs Avatar answered Dec 04 '22 13:12

hobbs