Fix: install Go 1.26.3 directly, use GOTOOLCHAIN=local (no runtime download)

This commit is contained in:
2026-05-11 09:04:15 +02:00
parent 2c53125298
commit 4c7690c270
+22 -10
View File
@@ -42,37 +42,49 @@ function Download-File($url, $dest) {
} }
# 1. Go pruefen / als ZIP installieren (kein MSI = kein Exit 1603) # 1. Go pruefen / als ZIP installieren (kein MSI = kein Exit 1603)
Write-Host "[1/3] Pruefe Go..." # upterm benoetigt Go >= 1.26 - direkt richtige Version installieren
Write-Host "[1/3] Pruefe Go (benoetigt >= 1.26)..."
$goRoot = "C:\Go" $goRoot = "C:\Go"
$goExe = "$goRoot\bin\go.exe" $goExe = "$goRoot\bin\go.exe"
$goVersion = "1.26.3"
if (-not (Test-Path $goExe)) { $needsInstall = $true
$goVersion = "1.22.4" if (Test-Path $goExe) {
$verLine = (& $goExe version 2>&1).ToString()
if ($verLine -match 'go(\d+)\.(\d+)') {
$major = [int]$Matches[1]; $minor = [int]$Matches[2]
if ($major -gt 1 -or ($major -eq 1 -and $minor -ge 26)) {
$needsInstall = $false
Write-Host " OK ($verLine)"
} else {
Write-Host " Go $major.$minor zu alt - aktualisiere auf $goVersion..."
Remove-Item -Recurse -Force $goRoot -ErrorAction SilentlyContinue
}
}
}
if ($needsInstall) {
$goZip = "C:\Windows\Temp\go-windows.zip" $goZip = "C:\Windows\Temp\go-windows.zip"
$goUrl = "https://golang.org/dl/go$goVersion.windows-amd64.zip" $goUrl = "https://golang.org/dl/go$goVersion.windows-amd64.zip"
Write-Host " Lade go$goVersion (ZIP) herunter..."
Write-Host " Go nicht gefunden - lade go$goVersion (ZIP) herunter..."
if (-not (Download-File $goUrl $goZip)) { if (-not (Download-File $goUrl $goZip)) {
Read-Host "Enter zum Beenden"; exit 1 Read-Host "Enter zum Beenden"; exit 1
} }
Write-Host " Entpacke nach $goRoot ..." Write-Host " Entpacke nach $goRoot ..."
if (Test-Path $goRoot) { Remove-Item -Recurse -Force $goRoot } if (Test-Path $goRoot) { Remove-Item -Recurse -Force $goRoot }
Expand-Archive -Path $goZip -DestinationPath "C:\" -Force Expand-Archive -Path $goZip -DestinationPath "C:\" -Force
Remove-Item $goZip -ErrorAction SilentlyContinue Remove-Item $goZip -ErrorAction SilentlyContinue
if (-not (Test-Path $goExe)) { if (-not (Test-Path $goExe)) {
Write-Host "FEHLER: go.exe nach Entpacken nicht gefunden." Write-Host "FEHLER: go.exe nach Entpacken nicht gefunden."
Read-Host "Enter zum Beenden"; exit 1 Read-Host "Enter zum Beenden"; exit 1
} }
Write-Host " OK (go$goVersion installiert)"
} }
# Go in PATH dieser Session # Go in PATH dieser Session
if ($env:PATH -notlike "*$goRoot\bin*") { if ($env:PATH -notlike "*$goRoot\bin*") {
$env:PATH = "$env:PATH;$goRoot\bin" $env:PATH = "$env:PATH;$goRoot\bin"
} }
$goVer = & $goExe version 2>&1
Write-Host " OK ($goVer)"
# 2. upterm bauen via Quellcode-ZIP # 2. upterm bauen via Quellcode-ZIP
# (go install erlaubt keine replace-Direktiven in externen Modulen) # (go install erlaubt keine replace-Direktiven in externen Modulen)
@@ -104,7 +116,7 @@ $env:TMP = "C:\GoTemp"
$env:GOCACHE = "C:\GoCache" $env:GOCACHE = "C:\GoCache"
$env:GOTMPDIR = "C:\GoTemp" $env:GOTMPDIR = "C:\GoTemp"
Push-Location $repoDir Push-Location $repoDir
$env:GOTOOLCHAIN = "auto" $env:GOTOOLCHAIN = "local"
& $goExe build -o "$env:GOPATH\bin\upterm.exe" ./cmd/upterm 2>&1 | ForEach-Object { Write-Host " $_" } & $goExe build -o "$env:GOPATH\bin\upterm.exe" ./cmd/upterm 2>&1 | ForEach-Object { Write-Host " $_" }
$buildExit = $LASTEXITCODE $buildExit = $LASTEXITCODE
Pop-Location Pop-Location