Skip to content

Commit c495364

Browse files
adonovangopherbot
authored andcommitted
go/packages/gopackages: document -mode flag
Fixes golang/go#60995 Change-Id: I9bb9b2a95a1be7416e86a3759fd5aa7321f1fd06 Reviewed-on: https://go-review.googlesource.com/c/tools/+/506357 Auto-Submit: Alan Donovan <[email protected]> Run-TryBot: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent 87ad891 commit c495364

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

go/packages/gopackages/main.go

+17-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type application struct {
3434
Deps bool `flag:"deps" help:"show dependencies too"`
3535
Test bool `flag:"test" help:"include any tests implied by the patterns"`
3636
Mode string `flag:"mode" help:"mode (one of files, imports, types, syntax, allsyntax)"`
37-
Private bool `flag:"private" help:"show non-exported declarations too"`
37+
Private bool `flag:"private" help:"show non-exported declarations too (if -mode=syntax)"`
3838
PrintJSON bool `flag:"json" help:"print package in JSON form"`
3939
BuildFlags stringListValue `flag:"buildflag" help:"pass argument to underlying build system (may be repeated)"`
4040
}
@@ -56,6 +56,21 @@ func (app *application) DetailedHelp(f *flag.FlagSet) {
5656
Packages are specified using the notation of "go list",
5757
or other underlying build system.
5858
59+
The mode flag determines how much information is computed and printed
60+
for the specified packages. In order of increasing computational cost,
61+
the legal values are:
62+
63+
-mode=files shows only the names of the packages' files.
64+
-mode=imports also shows the imports. (This is the default.)
65+
-mode=types loads the compiler's export data and displays the
66+
type of each exported declaration.
67+
-mode=syntax parses and type checks syntax trees for the initial
68+
packages. (With the -private flag, the types of
69+
non-exported declarations are shown too.)
70+
Type information for dependencies is obtained from
71+
compiler export data.
72+
-mode=allsyntax is like -mode=syntax but applied to all dependencies.
73+
5974
Flags:
6075
`)
6176
f.PrintDefaults()
@@ -189,7 +204,7 @@ func (app *application) print(lpkg *packages.Package) {
189204
fmt.Printf("\t%s\n", err)
190205
}
191206

192-
// package members (TypeCheck or WholeProgram mode)
207+
// types of package members
193208
if lpkg.Types != nil {
194209
qual := types.RelativeTo(lpkg.Types)
195210
scope := lpkg.Types.Scope()

0 commit comments

Comments
 (0)