From 93d9035c9e8b129578d3a177fd90eb308e44a597 Mon Sep 17 00:00:00 2001 From: Shogo Hida Date: Wed, 10 May 2023 14:41:06 +0000 Subject: [PATCH] cmd/go/internal: update documentation of go test and go generate Fixes #57050 Change-Id: I46cac667ff78ac171c878f4366f8f01f58f1d27d GitHub-Last-Rev: 697c255ece18cd4772b76d62991474a7da2536d8 GitHub-Pull-Request: golang/go#57814 Reviewed-on: https://go-review.googlesource.com/c/go/+/461683 TryBot-Result: Gopher Robot Reviewed-by: Dmitri Shuralyov Run-TryBot: Dmitri Shuralyov Auto-Submit: Dmitri Shuralyov Reviewed-by: Bryan Mills --- src/cmd/go/alldocs.go | 9 +++++++++ src/cmd/go/internal/generate/generate.go | 5 +++++ src/cmd/go/internal/test/test.go | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 4314d771fba605..8bcbd3f7647eec 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -567,6 +567,11 @@ // generator, containing the Go toolchain and standard library. // $DOLLAR // A dollar sign. +// $PATH +// The $PATH of the parent process, with $GOROOT/bin +// placed at the beginning. This causes generators +// that execute 'go' commands to use the same 'go' +// as the parent 'go generate' command. // // Other than variable substitution and quoted-string evaluation, no // special processing such as "globbing" is performed on the command @@ -1703,6 +1708,10 @@ // error. (The go command's standard error is reserved for printing // errors building the tests.) // +// The go command places $GOROOT/bin at the beginning of $PATH +// in the test's environment, so that tests that execute +// 'go' commands use the same 'go' as the parent 'go test' command. +// // Go test runs in two different modes: // // The first, called local directory mode, occurs when go test is diff --git a/src/cmd/go/internal/generate/generate.go b/src/cmd/go/internal/generate/generate.go index 160a8723a055f1..50c68924797502 100644 --- a/src/cmd/go/internal/generate/generate.go +++ b/src/cmd/go/internal/generate/generate.go @@ -90,6 +90,11 @@ Go generate sets several variables when it runs the generator: generator, containing the Go toolchain and standard library. $DOLLAR A dollar sign. + $PATH + The $PATH of the parent process, with $GOROOT/bin + placed at the beginning. This causes generators + that execute 'go' commands to use the same 'go' + as the parent 'go generate' command. Other than variable substitution and quoted-string evaluation, no special processing such as "globbing" is performed on the command diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index e82ea720949777..97f2dbdbe6cd32 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -87,6 +87,10 @@ standard output, even if the test printed them to its own standard error. (The go command's standard error is reserved for printing errors building the tests.) +The go command places $GOROOT/bin at the beginning of $PATH +in the test's environment, so that tests that execute +'go' commands use the same 'go' as the parent 'go test' command. + Go test runs in two different modes: The first, called local directory mode, occurs when go test is