From a52082c2f25e7e6f4d86ab6f626ab64266e2b2a8 Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Mon, 29 Apr 2024 09:55:12 +0800 Subject: [PATCH 1/3] add ".exe" when cross compiling for windows --- cmd/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index de70999..3c4b964 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 on or for Windows, use .exe extension + if runtime.GOOS == "windows" || os.Getenv("GOOS") == "windows" { f += ".exe" } return f From 7feadb5e99c0ecb0426faa8c3b67744a9a34335b Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Mon, 29 Apr 2024 14:20:43 +0800 Subject: [PATCH 2/3] add ".exe" when cross compiling for windows or on windows without cross-compiling --- cmd/main.go | 5 +++-- go.mod | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 3c4b964..8dba365 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -16,6 +16,7 @@ package xcaddycmd import ( "bytes" + "cmp" "context" "encoding/json" "fmt" @@ -194,8 +195,8 @@ func runBuild(ctx context.Context, args []string) error { func getCaddyOutputFile() string { f := "." + string(filepath.Separator) + "caddy" - // compiling on or for Windows, use .exe extension - if runtime.GOOS == "windows" || os.Getenv("GOOS") == "windows" { + // compiling for Windows or compiling on windows without setting GOOS, use .exe extension + if cmp.Or(os.Getenv("GOOS"), runtime.GOOS) == "windows" { f += ".exe" } return f diff --git a/go.mod b/go.mod index 4d94301..68604f4 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/caddyserver/xcaddy -go 1.14 +go 1.22 require ( github.com/Masterminds/semver/v3 v3.2.1 From d3b1ba4deb36d3e52b5e77944642afc06138bbce Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Mon, 29 Apr 2024 14:28:03 +0800 Subject: [PATCH 3/3] wait until 1.23 is released --- cmd/main.go | 3 +-- go.mod | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 8dba365..0495e57 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -16,7 +16,6 @@ package xcaddycmd import ( "bytes" - "cmp" "context" "encoding/json" "fmt" @@ -196,7 +195,7 @@ func runBuild(ctx context.Context, args []string) error { func getCaddyOutputFile() string { f := "." + string(filepath.Separator) + "caddy" // compiling for Windows or compiling on windows without setting GOOS, use .exe extension - if cmp.Or(os.Getenv("GOOS"), runtime.GOOS) == "windows" { + if os.Getenv("GOOS") == "windows" || (os.Getenv("GOOS") == "" && runtime.GOOS == "windows") { f += ".exe" } return f diff --git a/go.mod b/go.mod index 68604f4..4d94301 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/caddyserver/xcaddy -go 1.22 +go 1.14 require ( github.com/Masterminds/semver/v3 v3.2.1