From aeb422c2894fd20aeba2c1c85d21e2ce488457ec Mon Sep 17 00:00:00 2001 From: bakito Date: Sun, 18 Sep 2022 10:31:04 +0200 Subject: [PATCH] rename to exe in windows --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index be0f112..8b6d032 100644 --- a/main.go +++ b/main.go @@ -180,7 +180,12 @@ func copyFile(dir string, file os.DirEntry, targetDir string, targetName string) return err } defer from.Close() - to, err := os.OpenFile(filepath.Join(targetDir, targetName), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755) + toName := targetName + if runtime.GOOS == "windows" && !strings.HasSuffix(toName, ".exe") { + toName += ".exe" + } + + to, err := os.OpenFile(filepath.Join(targetDir, toName), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755) if err != nil { return err }