Skip to content

Instantly share code, notes, and snippets.

@gleeblezoid
Last active June 21, 2020 19:50
Show Gist options
  • Save gleeblezoid/f14dbf18aae6eef200106e09c50ff620 to your computer and use it in GitHub Desktop.
Save gleeblezoid/f14dbf18aae6eef200106e09c50ff620 to your computer and use it in GitHub Desktop.
MultiBuild - Command strings for running `go build` for multiple platforms
/* For setting up executables for multiple OS's */
package main
import(
"fmt"
"strings"
)
func main(){
var os = map[string]string{
"darwin":"amd64",
"windows":"amd64",
"linux":"amd64",
}
const build_string = "env GOOS=key GOARCH=value go build path"
var package_import_path string
fmt.Println("Enter the path for your go file including the extension")
fmt.Scanln(&package_import_path)
for k,v := range os{
GOOS := strings.ReplaceAll(build_string,"key",k)
GOARCH := strings.ReplaceAll(GOOS,"value",v)
command := strings.ReplaceAll(GOARCH,"path",package_import_path)
fmt.Println(command)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment