- Rewrite complet en Go : exe unique sans _internal/, sans extraction temp - GUI Windows-native via github.com/lxn/walk (TableView, TextEdit, PushButton) - Meme fonctionnalites : check repos, pull, checkout, auto-update, logs - build.bat : go build -ldflags "-H windowsgui -s -w" -> 9.6 Mo, zero dependance Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
980 B
Go
41 lines
980 B
Go
//go:build windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
const createNoWindow = 0x08000000
|
|
|
|
// newGitCmd crée une commande git sans fenêtre console.
|
|
func newGitCmd(ctx context.Context, args []string, cwd string) *exec.Cmd {
|
|
cmd := exec.CommandContext(ctx, "git", args...)
|
|
if cwd != "" {
|
|
cmd.Dir = cwd
|
|
}
|
|
cmd.SysProcAttr = &windows.SysProcAttr{
|
|
CreationFlags: createNoWindow,
|
|
}
|
|
return cmd
|
|
}
|
|
|
|
// relaunchAfterUpdate crée un batch qui attend 1s, relance l'exe et nettoie le .old.
|
|
func relaunchAfterUpdate(exePath string) {
|
|
oldPath := exePath + ".old"
|
|
batPath := exePath + "_update.bat"
|
|
content := fmt.Sprintf(
|
|
"@echo off\r\ntimeout /t 1 /nobreak >nul\r\nstart \"\" \"%s\"\r\ndel \"%s\" 2>nul\r\ndel \"%%~f0\"\r\n",
|
|
exePath, oldPath,
|
|
)
|
|
os.WriteFile(batPath, []byte(content), 0644)
|
|
cmd := exec.Command("cmd", "/c", batPath)
|
|
cmd.SysProcAttr = &windows.SysProcAttr{CreationFlags: createNoWindow}
|
|
cmd.Start()
|
|
}
|