summaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/doc/doc.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2018-10-10 11:50:49 +1100
committerRob Pike <r@golang.org>2018-10-10 23:40:35 +0000
commit294d16c9c58187492baf1fd8bac034b5fecbf0ba (patch)
tree02bf9378eb65669f7a6c68f4984c37084f07521f /src/cmd/go/internal/doc/doc.go
parentd5e722034ab19d47377507f3606c1a72f484d7eb (diff)
downloadgo-git-294d16c9c58187492baf1fd8bac034b5fecbf0ba.tar.gz
cmd/doc: add a -src flag to show original source
It's long-desired but was blocked by #26835. That is now fixed, so it's easy. When -src is off, we behave as before. But with -src set, initialize the go/doc package to preserve the original AST and things flow very easily. With -src, since you're seeing inside the package source anyway it shows unexported fields and constants: you see the original source. But you still need -u to ask about them. Fixes #18807 Change-Id: I473e90323b4eff0735360274dc0d2d9dba16ff8b Reviewed-on: https://go-review.googlesource.com/c/140959 Reviewed-by: Andrew Gerrand <adg@golang.org> Run-TryBot: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/go/internal/doc/doc.go')
-rw-r--r--src/cmd/go/internal/doc/doc.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/go/internal/doc/doc.go b/src/cmd/go/internal/doc/doc.go
index 4e7dca082d..262bbb3ecb 100644
--- a/src/cmd/go/internal/doc/doc.go
+++ b/src/cmd/go/internal/doc/doc.go
@@ -112,6 +112,13 @@ Flags:
Treat a command (package main) like a regular package.
Otherwise package main's exported symbols are hidden
when showing the package's top-level documentation.
+ -src
+ Show the full source code for the symbol. This will
+ display the full Go source of its declaration and
+ definition, such as a function definition (including
+ the body), type declaration or enclosing const
+ block. The output may therefore include unexported
+ details.
-u
Show documentation for unexported as well as exported
symbols, methods, and fields.