Skip to content

Commit

Permalink
Only run compiled binary if same platform (fixes #20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed May 26, 2020
1 parent 23d4e0a commit 823a072
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cmd/xcaddy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,19 @@ func runBuild(ctx context.Context, args []string) error {
}

// prove the build is working by printing the version
if !filepath.IsAbs(output) {
output = "." + string(filepath.Separator) + output
}
fmt.Println()
fmt.Printf("%s version\n", output)
cmd := exec.Command(output, "version")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
log.Fatalf("[FATAL] %v", err)
if runtime.GOOS == os.Getenv("GOOS") && runtime.GOARCH == os.Getenv("GOARCH") {
if !filepath.IsAbs(output) {
output = "." + string(filepath.Separator) + output
}
fmt.Println()
fmt.Printf("%s version\n", output)
cmd := exec.Command(output, "version")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
log.Fatalf("[FATAL] %v", err)
}
}

return nil
Expand Down

0 comments on commit 823a072

Please sign in to comment.