Skip to content

Instantly share code, notes, and snippets.

@mattheusv
Last active June 7, 2019 12:31
Show Gist options
  • Save mattheusv/45d6d42c0c5c73872f79047ff002547b to your computer and use it in GitHub Desktop.
Save mattheusv/45d6d42c0c5c73872f79047ff002547b to your computer and use it in GitHub Desktop.
cross plataform compile with Go
package main
func main() {
say()
}
package main
import "fmt"
func say() {
fmt.Println("linux")
}
package main
import "fmt"
func say() {
fmt.Println("windows")
}
@mattheusv
Copy link
Author

mattheusv commented Jun 7, 2019

if you running in a linux amd 64 architeture, the program will print linux, or if you running in a windows amd 64 architeture, the program will print windows

OBS
if you add a function foo() in say_windows_amd64.gofile, and not put your linux version into say_linux_amd64.go, when you call this function on main function, the program will not compile, telling undefined foo()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment