Last active
June 21, 2020 19:50
-
-
Save gleeblezoid/f14dbf18aae6eef200106e09c50ff620 to your computer and use it in GitHub Desktop.
MultiBuild - Command strings for running `go build` for multiple platforms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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