aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/doc/testdata
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/doc/testdata
parentd5e722034ab19d47377507f3606c1a72f484d7eb (diff)
downloadgo-294d16c9c58187492baf1fd8bac034b5fecbf0ba.tar.xz
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/doc/testdata')
-rw-r--r--src/cmd/doc/testdata/pkg.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/doc/testdata/pkg.go b/src/cmd/doc/testdata/pkg.go
index bc069939f8..50105b5fcc 100644
--- a/src/cmd/doc/testdata/pkg.go
+++ b/src/cmd/doc/testdata/pkg.go
@@ -5,6 +5,8 @@
// Package comment.
package pkg
+import "io"
+
// Constants
// Comment about exported constant.
@@ -52,7 +54,9 @@ var (
)
// Comment about exported function.
-func ExportedFunc(a int) bool
+func ExportedFunc(a int) bool {
+ return true != false
+}
// Comment about internal function.
func internalFunc(a int) bool
@@ -73,7 +77,7 @@ type ExportedType struct {
// Comment about exported method.
func (ExportedType) ExportedMethod(a int) bool {
- return true
+ return true != true
}
// Comment about unexported method.