aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/doc/pkg.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-10-28 09:12:20 -0400
committerCherry Zhang <cherryyz@google.com>2020-10-28 09:12:20 -0400
commita16e30d162c1c7408db7821e7b9513cefa09c6ca (patch)
treeaf752ba9ba44c547df39bb0af9bff79f610ba9d5 /src/cmd/doc/pkg.go
parent91e4d2d57bc341dd82c98247117114c851380aef (diff)
parentcf6cfba4d5358404dd890f6025e573a4b2156543 (diff)
downloadgo-a16e30d162c1c7408db7821e7b9513cefa09c6ca.tar.gz
go-a16e30d162c1c7408db7821e7b9513cefa09c6ca.zip
[dev.link] all: merge branch 'master' into dev.linkdev.link
Clean merge. Change-Id: Ia7b2808bc649790198d34c226a61d9e569084dc5
Diffstat (limited to 'src/cmd/doc/pkg.go')
-rw-r--r--src/cmd/doc/pkg.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/doc/pkg.go b/src/cmd/doc/pkg.go
index ffc302c78c..c2e06ebc8b 100644
--- a/src/cmd/doc/pkg.go
+++ b/src/cmd/doc/pkg.go
@@ -16,8 +16,8 @@ import (
"go/printer"
"go/token"
"io"
+ "io/fs"
"log"
- "os"
"path/filepath"
"strings"
"unicode"
@@ -129,11 +129,10 @@ func (pkg *Package) Fatalf(format string, args ...interface{}) {
// parsePackage turns the build package we found into a parsed package
// we can then use to generate documentation.
func parsePackage(writer io.Writer, pkg *build.Package, userPath string) *Package {
- fs := token.NewFileSet()
// include tells parser.ParseDir which files to include.
// That means the file must be in the build package's GoFiles or CgoFiles
// list only (no tag-ignored files, tests, swig or other non-Go files).
- include := func(info os.FileInfo) bool {
+ include := func(info fs.FileInfo) bool {
for _, name := range pkg.GoFiles {
if name == info.Name() {
return true
@@ -146,7 +145,8 @@ func parsePackage(writer io.Writer, pkg *build.Package, userPath string) *Packag
}
return false
}
- pkgs, err := parser.ParseDir(fs, pkg.Dir, include, parser.ParseComments)
+ fset := token.NewFileSet()
+ pkgs, err := parser.ParseDir(fset, pkg.Dir, include, parser.ParseComments)
if err != nil {
log.Fatal(err)
}
@@ -203,7 +203,7 @@ func parsePackage(writer io.Writer, pkg *build.Package, userPath string) *Packag
typedValue: typedValue,
constructor: constructor,
build: pkg,
- fs: fs,
+ fs: fset,
}
p.buf.pkg = p
return p