From bff687835ec7f191c498e8fd01e18e556cc93146 Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Tue, 7 May 2024 01:38:01 +0800 Subject: [PATCH] add ".exe" when cross compiling for windows (#179) * add ".exe" when cross compiling for windows * add ".exe" when cross compiling for windows or on windows without cross-compiling * wait until 1.23 is released --- cmd/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index de70999..0495e57 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -194,7 +194,8 @@ func runBuild(ctx context.Context, args []string) error { func getCaddyOutputFile() string { f := "." + string(filepath.Separator) + "caddy" - if runtime.GOOS == "windows" { + // compiling for Windows or compiling on windows without setting GOOS, use .exe extension + if os.Getenv("GOOS") == "windows" || (os.Getenv("GOOS") == "" && runtime.GOOS == "windows") { f += ".exe" } return f