go/packages: update doc for name= queries

Change-Id: I2ba387703ae1f31e7dff271007607f377701f7dd
Reviewed-on: https://go-review.googlesource.com/c/155941
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Zac Bergquist 2018-12-31 11:15:34 -07:00 committed by Michael Matloob
parent 7cb465e007
commit 1bc491975c
1 changed files with 5 additions and 6 deletions

View File

@ -19,21 +19,20 @@ but all patterns with the prefix "query=", where query is a
non-empty string of letters from [a-z], are reserved and may be non-empty string of letters from [a-z], are reserved and may be
interpreted as query operators. interpreted as query operators.
Only two query operators are currently supported, "file" and "pattern". Three query operators are currently supported: "file", "pattern", and "name".
The query "file=path/to/file.go" matches the package or packages enclosing The query "file=path/to/file.go" matches the package or packages enclosing
the Go source file path/to/file.go. For example "file=~/go/src/fmt/print.go" the Go source file path/to/file.go. For example "file=~/go/src/fmt/print.go"
might returns the packages "fmt" and "fmt [fmt.test]". might return the packages "fmt" and "fmt [fmt.test]".
The query "pattern=string" causes "string" to be passed directly to The query "pattern=string" causes "string" to be passed directly to
the underlying build tool. In most cases this is unnecessary, the underlying build tool. In most cases this is unnecessary,
but an application can use Load("pattern=" + x) as an escaping mechanism but an application can use Load("pattern=" + x) as an escaping mechanism
to ensure that x is not interpreted as a query operator if it contains '='. to ensure that x is not interpreted as a query operator if it contains '='.
A third query "name=identifier" will be added soon. The query "name=identifier" matches packages whose package declaration contains
It will match packages whose package declaration contains the specified identifier. the specified identifier. For example, "name=rand" would match the packages
For example, "name=rand" would match the packages "math/rand" and "crypto/rand", "math/rand" and "crypto/rand", and "name=main" would match all executables.
and "name=main" would match all executables.
All other query operators are reserved for future use and currently All other query operators are reserved for future use and currently
cause Load to report an error. cause Load to report an error.