From 13c49c35669aed7b08f33756f700309e00b3b2d4 Mon Sep 17 00:00:00 2001 From: Jayson Reis Date: Wed, 26 Aug 2020 20:36:51 +0200 Subject: [PATCH] Fix runDev when running on windows (#33) Extract default output file to a function and reuse it in both runBuild and runDev --- cmd/xcaddy/main.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/xcaddy/main.go b/cmd/xcaddy/main.go index 50def87..43c150f 100644 --- a/cmd/xcaddy/main.go +++ b/cmd/xcaddy/main.go @@ -99,11 +99,7 @@ func runBuild(ctx context.Context, args []string) error { // ensure an output file is always specified if output == "" { - if runtime.GOOS == "windows" { - output = "caddy.exe" - } else { - output = "caddy" - } + output = getCaddyOutputFile() } // perform the build @@ -141,8 +137,15 @@ func runBuild(ctx context.Context, args []string) error { return nil } +func getCaddyOutputFile() string { + if runtime.GOOS == "windows" { + return "caddy.exe" + } + return "caddy" +} + func runDev(ctx context.Context, args []string) error { - const binOutput = "./caddy" + binOutput := getCaddyOutputFile() // get current/main module name cmd := exec.Command("go", "list", "-m")