aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/doc
diff options
context:
space:
mode:
authorRoi Martin <jroi.martin@gmail.com>2021-11-25 13:47:39 +0100
committerIan Lance Taylor <iant@golang.org>2021-11-26 20:49:40 +0000
commitbf88adadac9bbb1b190ba7af1010373823dabb06 (patch)
tree7ebbf20375534c834ae050374cb7ac6ea60e31b9 /src/cmd/doc
parent77038044ca7b11fce7eb11f3e6115ed753c2c2bd (diff)
downloadgo-bf88adadac9bbb1b190ba7af1010373823dabb06.tar.gz
go-bf88adadac9bbb1b190ba7af1010373823dabb06.zip
cmd/doc: fix "builtin" package parsing
As stated in the code, "The builtin package needs special treatment: its symbols are lower case but we want to see them, always". Thus, cmd/doc forces the -u flag if the package being queried is called "builtin". However, this happens after having already parsed the package. This CL forces the -u flag just after parsing the command arguments and before parsing any package. Fixes #49796. Change-Id: If690a900c7cfd1700feecb9529bd4344c3c249d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/367134 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Diffstat (limited to 'src/cmd/doc')
-rw-r--r--src/cmd/doc/main.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/cmd/doc/main.go b/src/cmd/doc/main.go
index 0499c40369..dee5d7bbcd 100644
--- a/src/cmd/doc/main.go
+++ b/src/cmd/doc/main.go
@@ -110,6 +110,13 @@ func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) {
if buildPackage == nil {
return fmt.Errorf("no such package: %s", userPath)
}
+
+ // The builtin package needs special treatment: its symbols are lower
+ // case but we want to see them, always.
+ if buildPackage.ImportPath == "builtin" {
+ unexported = true
+ }
+
symbol, method = parseSymbol(sym)
pkg := parsePackage(writer, buildPackage, userPath)
paths = append(paths, pkg.prettyPath())
@@ -128,12 +135,6 @@ func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) {
panic(e)
}()
- // The builtin package needs special treatment: its symbols are lower
- // case but we want to see them, always.
- if pkg.build.ImportPath == "builtin" {
- unexported = true
- }
-
// We have a package.
if showAll && symbol == "" {
pkg.allDoc()