1
0
mirror of https://github.com/golang/go synced 2024-11-17 08:24:43 -07:00
go/src/run.bat
Russ Cox bb6efb9609 build: set GOPATH consistently in run.bash, run.bat, run.rc
We used to clear GOPATH in all the build scripts.
Clearing GOPATH is misleading at best, since you just end up
with the default GOPATH (%USERPROFILE%\go on Windows).
Unless that's your GOROOT, in which case you end up with a
fatal error from the go command (#43938).

run.bash changed to setting GOPATH=/dev/null, which has no
clear analogue on Windows.

run.rc still clears GOPATH.

Change them all to set GOPATH to a non-existent directory
/nonexist-gopath or c:\nonexist-gopath.

Change-Id: I51edd66d37ff6a891b0d0541d91ecba97fbbb03d
Reviewed-on: https://go-review.googlesource.com/c/go/+/288818
Trust: Russ Cox <rsc@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-19 00:04:56 +00:00

53 lines
1.0 KiB
Batchfile

:: Copyright 2012 The Go Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style
:: license that can be found in the LICENSE file.
@echo off
if exist ..\bin\go.exe goto ok
echo Must run run.bat from Go src directory after installing cmd/go.
goto fail
:ok
:: Keep environment variables within this script
:: unless invoked with --no-local.
if x%1==x--no-local goto nolocal
if x%2==x--no-local goto nolocal
setlocal
:nolocal
set GOBUILDFAIL=0
set GOPATH=c:\nonexist-gopath
:: Issue 14340: ignore GOBIN during all.bat.
set GOBIN=
set GOFLAGS=
set GO111MODULE=
rem TODO avoid rebuild if possible
if x%1==x--no-rebuild goto norebuild
echo ##### Building packages and commands.
..\bin\go install -a -v std cmd
if errorlevel 1 goto fail
echo.
:norebuild
:: get CGO_ENABLED
..\bin\go env > env.bat
if errorlevel 1 goto fail
call env.bat
del env.bat
echo.
..\bin\go tool dist test
if errorlevel 1 goto fail
echo.
goto end
:fail
set GOBUILDFAIL=1
:end