title: How do I cross compile my Go program from Mac OS X to Ubuntu 64-bit
body: <p>As the title says I'm wondering how to cross-compile my program so that I can run it on Ubuntu 64-bit</p>
  
  <p>I've went into the <code>/usr/local/go/src</code> folder and ran </p>
  
  <p><code>GOOS=linux GOARCH=amd64 ./make.bash --no-clean</code></p>
  
  <p>everything compiled fine</p>
  
  <p>then went into my project directory and ran <code>go build -v -a</code> and then took the compiled binary and moved it to my linux server, but when running it I get this error:</p>
  
  <pre><code>root@PanicCSGO40:~/test# ./test
  -bash: ./test: cannot execute binary file: Exec format error
  root@PanicCSGO40:~/test# sudo ./test
  ./test: 1: ./test: Syntax error: "(" unexpected
  root@PanicCSGO40:~/test#
  </code></pre>
  
  <p>Not sure what I am doing wrong any information would be great thanks.</p>
  
  <p>I've also tried doing it with <code>GOARCH=386</code> but still get the same errors. Thanks!</p>
  
  <p><a href="https://stackoverflow.com/questions/23377271/how-do-i-cross-compile-a-go-program-on-a-mac-for-ubuntu">This link</a> does not solve my question because the chosen answer is a link to a blog post which relies heavily on doing all cross-compilation on using the blog writers <code>bash</code> scripts to do it, I just simply wanted to know what the correct way to do it was and now I do.</p>