Skip to content

Commit 1153928

Browse files
adonovangopherbot
authored andcommitted
go/packages: improve docs of 'go list' and GOPACKAGESDRIVER
Fixes golang/go#34341 Updates golang/go#64608 Change-Id: I3b41660c12942fdb15b8ea6f1f3c0b77ae91b897 Reviewed-on: https://go-review.googlesource.com/c/tools/+/547977 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent c4e846a commit 1153928

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

go/packages/doc.go

+27-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,32 @@
55
/*
66
Package packages loads Go packages for inspection and analysis.
77
8-
The Load function takes as input a list of patterns and return a list of Package
9-
structs describing individual packages matched by those patterns.
10-
The LoadMode controls the amount of detail in the loaded packages.
11-
12-
Load passes most patterns directly to the underlying build tool,
13-
but all patterns with the prefix "query=", where query is a
8+
The [Load] function takes as input a list of patterns and returns a
9+
list of [Package] values describing individual packages matched by those
10+
patterns.
11+
A [Config] specifies configuration options, the most important of which is
12+
the [LoadMode], which controls the amount of detail in the loaded packages.
13+
14+
Load passes most patterns directly to the underlying build tool.
15+
The default build tool is the go command.
16+
Its supported patterns are described at
17+
https://pkg.go.dev/cmd/go#hdr-Package_lists_and_patterns.
18+
19+
Load may be used in Go projects that use alternative build systems, by
20+
installing an appropriate "driver" program for the build system and
21+
specifying its location in the GOPACKAGESDRIVER environment variable.
22+
For example,
23+
https://github.com/bazelbuild/rules_go/wiki/Editor-and-tool-integration
24+
explains how to use the driver for Bazel.
25+
The driver program is responsible for interpreting patterns in its
26+
preferred notation and reporting information about the packages that
27+
they identify.
28+
(See driverRequest and driverResponse types for the JSON
29+
schema used by the protocol.
30+
Though the protocol is supported, these types are currently unexported;
31+
see #64608 for a proposal to publish them.)
32+
33+
Regardless of driver, all patterns with the prefix "query=", where query is a
1434
non-empty string of letters from [a-z], are reserved and may be
1535
interpreted as query operators.
1636
@@ -64,7 +84,7 @@ reported about the loaded packages. See the documentation for type LoadMode
6484
for details.
6585
6686
Most tools should pass their command-line arguments (after any flags)
67-
uninterpreted to the loader, so that the loader can interpret them
87+
uninterpreted to [Load], so that it can interpret them
6888
according to the conventions of the underlying build system.
6989
See the Example function for typical usage.
7090
*/

0 commit comments

Comments
 (0)