@echo off
setlocal
cd /d "%~dp0"

where go >nul 2>nul
if errorlevel 1 goto :nogo

echo [1/3] go test ./...
go test ./...
if errorlevel 1 goto :fail

echo [2/3] go vet ./...
go vet ./...
if errorlevel 1 goto :fail

echo [3/3] go build
go build -trimpath -ldflags="-s -w -H=windowsgui" -o "..\CorpseColorPillarInstaller.exe" .
if errorlevel 1 goto :fail

echo.
echo Build succeeded:
echo %~dp0..\CorpseColorPillarInstaller.exe
pause
exit /b 0

:nogo
echo Go was not found in PATH.
pause
exit /b 1

:fail
echo.
echo Build failed. See the error output above.
pause
exit /b 1
