]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/go, go/build: parse directives in file headers
authorRuss Cox <rsc@golang.org>
Tue, 29 Nov 2022 18:30:50 +0000 (13:30 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 23 Feb 2023 10:10:21 +0000 (10:10 +0000)
commitbd8ec78b08ead1fb34ec8dc7bc4bf2ff7a9e8b82
treea9a2e48a8fd8551cbc3fc39dc91a6ae8e0682f50
parentf07fafacef04e8a8eaf2c8d2e1a14dc88e8683ee
cmd/go, go/build: parse directives in file headers

For #56986, go/build needs to report up to cmd/go
about //go:debug lines found in the source code.
Rather than make a special case for //go:debug,
this change gathers all top-level directives above the
package line and includes them in the result.

The go command's module index must match go/build,
so this CL contains the code to update the index as well.

A future CL will use the //go:debug lines to prepare the default
GODEBUG settings, as well as rejecting such lines in non-main
packages.

Change-Id: I66ab8dc72f9cd65c503b10b744367caca233f8a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/453603
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
16 files changed:
api/next/56986.txt [new file with mode: 0644]
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/modindex/build.go
src/cmd/go/internal/modindex/build_read.go
src/cmd/go/internal/modindex/read.go
src/cmd/go/internal/modindex/scan.go
src/cmd/go/internal/modindex/write.go
src/go/build/build.go
src/go/build/build_test.go
src/go/build/read.go
src/go/build/testdata/directives/a.go [new file with mode: 0644]
src/go/build/testdata/directives/a_test.go [new file with mode: 0644]
src/go/build/testdata/directives/b_test.go [new file with mode: 0644]
src/go/build/testdata/directives/c_test.go [new file with mode: 0644]
src/go/build/testdata/directives/d_test.go [new file with mode: 0644]
src/go/build/testdata/directives/eve.go [new file with mode: 0644]