From 77cfe1d0e2387645299085c8ed1afdf3a38cc2f2 Mon Sep 17 00:00:00 2001 From: unapiedra Date: Fri, 1 Apr 2016 00:27:26 +0200 Subject: [PATCH] Updated page to reflect status with Go 1.5 and newer. --- WindowsCrossCompiling.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/WindowsCrossCompiling.md b/WindowsCrossCompiling.md index 7b957537..c85b4c76 100644 --- a/WindowsCrossCompiling.md +++ b/WindowsCrossCompiling.md @@ -1,5 +1,28 @@ # Building windows go programs on linux +## Go version >= 1.5 + +Since Go version 1.5 cross-compiling has become very easy. Try it out with the code below. More can be found at this blog post by [Dave Cheney][1]. + +[1]: http://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5 + +```go +$ cat hello.go +package main + +import "fmt" + +func main() { + fmt.Printf("Hello\n") +} +$ GOOS=windows GOARCH=386 go build -o hello.exe hello.go +``` + +You can now run `hello.exe` on a Windows machine near you. + + +## Older Go version (<1.5) + I use linux/386, but, I suspect, this procedure will apply to other host platforms as well. Preparation (if needed):