diff options
| author | qmuntal <quimmuntal@gmail.com> | 2025-02-11 09:17:08 +0100 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-02-11 09:45:10 -0800 |
| commit | e9eb88ae7291bf9f1b05e8e4860474c734c5448d (patch) | |
| tree | 28e98518dc24a373efd01769156d399d8516ac4d /src/make.bat | |
| parent | 450f3f608d409e2b3d76af071ec726efacbdd17b (diff) | |
| download | go-e9eb88ae7291bf9f1b05e8e4860474c734c5448d.tar.xz | |
{all,clean,make,race,run}.bat: simplify error handling
The bat files can use "if" + parentheses to make it easier to
understand how the if-case is handled rather than the more cryptic
"if" + "goto".
While here, replace some "goto"s with direct "exit" calls.
Change-Id: I20e1804439b5088f8f1e5cbf8676f3d58560109d
Reviewed-on: https://go-review.googlesource.com/c/go/+/648375
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/make.bat')
| -rw-r--r-- | src/make.bat | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/make.bat b/src/make.bat index 0d5dd2761a..890829131b 100644 --- a/src/make.bat +++ b/src/make.bat @@ -36,10 +36,10 @@ setlocal
-if exist make.bat goto ok
-echo Must run make.bat from Go src directory.
-goto fail
-:ok
+if not exist make.bat (
+ echo Must run make.bat from Go src directory.
+ exit /b 1
+)
:: Clean old generated file that will cause problems in the build.
del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
@@ -78,7 +78,11 @@ if "x%GOROOT_BOOTSTRAP%"=="x" if exist "%HOMEDRIVE%%HOMEPATH%\sdk\go%bootgo%" se if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4
:bootstrapset
-if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" goto bootstrapfail
+if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" (
+ echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
+ echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%.
+ exit /b 1
+)
set GOROOT=%GOROOT_TEMP%
set GOROOT_TEMP=
@@ -90,9 +94,9 @@ echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%. (%GOROOT_BOOTSTRAP_VERSION%) if x%vflag==x-v echo cmd/dist
set GOROOT=%GOROOT_BOOTSTRAP%
set GOBIN=
-"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist || goto fail
+"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist || exit /b 1
endlocal
-.\cmd\dist\dist.exe env -w -p >env.bat || goto fail
+.\cmd\dist\dist.exe env -w -p >env.bat || exit /b 1
call .\env.bat
del env.bat
if x%vflag==x-v echo.
@@ -109,7 +113,7 @@ if x%4==x--dist-tool goto copydist :: Run dist bootstrap to complete make.bash.
:: Bootstrap installs a proper cmd/dist, built with the new toolchain.
:: Throw ours, built with the bootstrap toolchain, away after bootstrap.
-.\cmd\dist\dist.exe bootstrap -a %* || goto fail
+.\cmd\dist\dist.exe bootstrap -a %* || exit /b 1
del .\cmd\dist\dist.exe
goto :eof
@@ -131,11 +135,3 @@ set GOOS= set GOARCH=
set GOEXPERIMENT=
set GOFLAGS=
-goto :eof
-
-:bootstrapfail
-echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
-echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%.
-
-:fail
-exit /b 1
|
