internal/godoc: remove pathpkg renaming

This makes various other code movement a bit nicer.

Change-Id: I89c46dcbf3019eead4922f4db301bf0ea82b697e
Reviewed-on: https://go-review.googlesource.com/c/website/+/296379
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/internal/godoc/dirtrees.go b/internal/godoc/dirtrees.go
index ddc2ae8..dde3ff1 100644
--- a/internal/godoc/dirtrees.go
+++ b/internal/godoc/dirtrees.go
@@ -15,7 +15,7 @@
 	"go/token"
 	"io/fs"
 	"log"
-	pathpkg "path"
+	"path"
 	"sort"
 	"strings"
 )
@@ -28,13 +28,13 @@
 }
 
 func (d *Directory) Name() string {
-	return pathpkg.Base(d.Path)
+	return path.Base(d.Path)
 }
 
 func isPkgFile(fi fs.DirEntry) bool {
 	name := fi.Name()
 	return !fi.IsDir() &&
-		pathpkg.Ext(name) == ".go" &&
+		path.Ext(name) == ".go" &&
 		!strings.HasSuffix(fi.Name(), "_test.go") // ignore test files
 }
 
@@ -45,16 +45,16 @@
 		len(name) > 0 && name[0] != '_' && name[0] != '.' // ignore _files and .files
 }
 
-func newDirTree(fsys fs.FS, fset *token.FileSet, path string) *Directory {
+func newDirTree(fsys fs.FS, fset *token.FileSet, abspath string) *Directory {
 	var synopses [3]string // prioritized package documentation (0 == highest priority)
 
 	hasPkgFiles := false
 	haveSummary := false
 
-	list, err := fs.ReadDir(fsys, toFS(path))
+	list, err := fs.ReadDir(fsys, toFS(abspath))
 	if err != nil {
 		// TODO: propagate more. See golang.org/issue/14252.
-		log.Printf("newDirTree reading %s: %v", path, err)
+		log.Printf("newDirTree reading %s: %v", abspath, err)
 	}
 
 	// determine number of subdirectories and if there are package files
@@ -63,7 +63,7 @@
 
 	for _, d := range list {
 		name := d.Name()
-		filename := pathpkg.Join(path, name)
+		filename := path.Join(abspath, name)
 		switch {
 		case isPkgDir(d):
 			dir := newDirTree(fsys, fset, filename)
@@ -131,7 +131,7 @@
 	}
 
 	return &Directory{
-		Path:     path,
+		Path:     abspath,
 		HasPkg:   hasPkgFiles,
 		Synopsis: synopsis,
 		Dirs:     dirs,
@@ -139,11 +139,11 @@
 }
 
 // toFS returns the io/fs name for path (no leading slash).
-func toFS(path string) string {
-	if path == "/" {
+func toFS(name string) string {
+	if name == "/" {
 		return "."
 	}
-	return pathpkg.Clean(strings.TrimPrefix(path, "/"))
+	return path.Clean(strings.TrimPrefix(name, "/"))
 }
 
 // walk calls f(d, depth) for each directory d in the tree rooted at dir, including dir itself.
@@ -160,32 +160,32 @@
 	}
 }
 
-// lookup looks for the *Directory for a given path, relative to dir.
-func (dir *Directory) lookup(path string) *Directory {
-	path = pathpkg.Join(dir.Path, path)
-	if path == dir.Path {
+// lookup looks for the *Directory for a given named path, relative to dir.
+func (dir *Directory) lookup(name string) *Directory {
+	name = path.Join(dir.Path, name)
+	if name == dir.Path {
 		return dir
 	}
 	dirPathLen := len(dir.Path)
 	if dir.Path == "/" {
 		dirPathLen = 0 // so path[dirPathLen] is a slash
 	}
-	if !strings.HasPrefix(path, dir.Path) || path[dirPathLen] != '/' {
-		println("NO", path, dir.Path)
+	if !strings.HasPrefix(name, dir.Path) || name[dirPathLen] != '/' {
+		println("NO", name, dir.Path)
 		return nil
 	}
 	d := dir
 Walk:
-	for i := dirPathLen + 1; i <= len(path); i++ {
-		if i == len(path) || path[i] == '/' {
+	for i := dirPathLen + 1; i <= len(name); i++ {
+		if i == len(name) || name[i] == '/' {
 			// Find next child along path.
 			for _, sub := range d.Dirs {
-				if sub.Path == path[:i] {
+				if sub.Path == name[:i] {
 					d = sub
 					continue Walk
 				}
 			}
-			println("LOST", path[:i])
+			println("LOST", name[:i])
 			return nil
 		}
 	}
@@ -203,7 +203,7 @@
 }
 
 func (d *DirEntry) Name() string {
-	return pathpkg.Base(d.Path)
+	return path.Base(d.Path)
 }
 
 type DirList struct {
diff --git a/internal/godoc/godoc.go b/internal/godoc/godoc.go
index 6031666..7117b5a 100644
--- a/internal/godoc/godoc.go
+++ b/internal/godoc/godoc.go
@@ -13,7 +13,7 @@
 	"go/ast"
 	"go/doc"
 	"go/token"
-	pathpkg "path"
+	"path"
 	"strconv"
 	"strings"
 	"text/template"
@@ -76,8 +76,8 @@
 
 func multiply(a, b int) int { return a * b }
 
-func filenameFunc(path string) string {
-	_, localname := pathpkg.Split(path)
+func filenameFunc(name string) string {
+	_, localname := path.Split(name)
 	return localname
 }
 
@@ -119,7 +119,7 @@
 // documentation of relpath.
 func srcToPkgLinkFunc(relpath string) string {
 	relpath = pkgLinkFunc(relpath)
-	relpath = pathpkg.Dir(relpath)
+	relpath = path.Dir(relpath)
 	if relpath == "pkg" {
 		return `<a href="/pkg">Index</a>`
 	}
@@ -212,7 +212,7 @@
 }
 
 func srcLinkFunc(s string) string {
-	s = pathpkg.Clean("/" + s)
+	s = path.Clean("/" + s)
 	if !strings.HasPrefix(s, "/src/") {
 		s = "/src" + s
 	}
@@ -225,7 +225,7 @@
 // query is expected to be a string that has already been appropriately escaped
 // for use in a URL query.
 func queryLinkFunc(s, query string, line int) string {
-	url := pathpkg.Clean("/"+s) + "?h=" + query
+	url := path.Clean("/"+s) + "?h=" + query
 	if line > 0 {
 		url += "#L" + strconv.Itoa(line)
 	}
@@ -233,5 +233,5 @@
 }
 
 func docLinkFunc(s string, ident string) string {
-	return pathpkg.Clean("/pkg/"+s) + "/#" + ident
+	return path.Clean("/pkg/"+s) + "/#" + ident
 }
diff --git a/internal/godoc/meta.go b/internal/godoc/meta.go
index da5d633..14ff6b8 100644
--- a/internal/godoc/meta.go
+++ b/internal/godoc/meta.go
@@ -14,7 +14,7 @@
 	"io/fs"
 	"log"
 	"os"
-	pathpkg "path"
+	"path"
 	"strings"
 	"time"
 )
@@ -79,7 +79,7 @@
 			return
 		}
 		for _, fi := range fis {
-			name := pathpkg.Join(dir, fi.Name())
+			name := path.Join(dir, fi.Name())
 			if fi.IsDir() {
 				scan(name) // recurse
 				continue
diff --git a/internal/godoc/parser.go b/internal/godoc/parser.go
index ec03639..b375ddb 100644
--- a/internal/godoc/parser.go
+++ b/internal/godoc/parser.go
@@ -16,7 +16,7 @@
 	"go/parser"
 	"go/token"
 	"io/fs"
-	pathpkg "path"
+	"path"
 )
 
 var linePrefix = []byte("//line ")
@@ -64,12 +64,12 @@
 func parseFiles(fsys fs.FS, fset *token.FileSet, relpath string, abspath string, localnames []string) (map[string]*ast.File, error) {
 	files := make(map[string]*ast.File)
 	for _, f := range localnames {
-		absname := pathpkg.Join(abspath, f)
+		absname := path.Join(abspath, f)
 		file, err := parseFile(fsys, fset, absname, parser.ParseComments)
 		if err != nil {
 			return nil, err
 		}
-		files[pathpkg.Join(relpath, f)] = file
+		files[path.Join(relpath, f)] = file
 	}
 
 	return files, nil
diff --git a/internal/godoc/server.go b/internal/godoc/server.go
index a16a95c..8547bcf 100644
--- a/internal/godoc/server.go
+++ b/internal/godoc/server.go
@@ -22,7 +22,7 @@
 	"log"
 	"net/http"
 	"os"
-	pathpkg "path"
+	"path"
 	"path/filepath"
 	"regexp"
 	"sort"
@@ -74,7 +74,7 @@
 	// Note: If goos/goarch aren't set, the current binary's GOOS/GOARCH
 	// are used.
 	ctxt := build.Default
-	ctxt.IsAbsPath = pathpkg.IsAbs
+	ctxt.IsAbsPath = path.IsAbs
 	ctxt.IsDir = func(path string) bool {
 		fi, err := fs.Stat(d.fs, toFS(filepath.ToSlash(path)))
 		return err == nil && fi.IsDir()
@@ -159,7 +159,7 @@
 			if mode&AllMethods != 0 {
 				m |= doc.AllMethods
 			}
-			info.PDoc = doc.New(pkg, pathpkg.Clean(relpath), m) // no trailing '/' in importpath
+			info.PDoc = doc.New(pkg, path.Clean(relpath), m) // no trailing '/' in importpath
 			if mode&NoTypeAssoc != 0 {
 				for _, t := range info.PDoc.Types {
 					info.PDoc.Consts = append(info.PDoc.Consts, t.Consts...)
@@ -227,9 +227,9 @@
 	}
 
 	// TODO(rsc): URL should be clean already.
-	relpath := pathpkg.Clean(strings.TrimPrefix(r.URL.Path, "/pkg/"))
+	relpath := path.Clean(strings.TrimPrefix(r.URL.Path, "/pkg/"))
 
-	abspath := pathpkg.Join("/src", relpath)
+	abspath := path.Join("/src", relpath)
 	mode := GetPageInfoMode(r.FormValue("m"))
 	if relpath == "builtin" {
 		// The fake built-in package contains unexported identifiers,
@@ -260,7 +260,7 @@
 	if title == "" {
 		if info.IsMain {
 			// assume that the directory name is the command name
-			_, tabtitle = pathpkg.Split(relpath)
+			_, tabtitle = path.Split(relpath)
 			title = "Command "
 		} else {
 			title = "Package "
@@ -481,7 +481,7 @@
 }
 
 func redirect(w http.ResponseWriter, r *http.Request) (redirected bool) {
-	canonical := pathpkg.Clean(r.URL.Path)
+	canonical := path.Clean(r.URL.Path)
 	if !strings.HasSuffix(canonical, "/") {
 		canonical += "/"
 	}
@@ -495,7 +495,7 @@
 }
 
 func redirectFile(w http.ResponseWriter, r *http.Request) (redirected bool) {
-	c := pathpkg.Clean(r.URL.Path)
+	c := path.Clean(r.URL.Path)
 	c = strings.TrimRight(c, "/")
 	if r.URL.Path != c {
 		url := *r.URL
@@ -537,7 +537,7 @@
 	}
 
 	cfg := texthtml.Config{
-		GoComments: pathpkg.Ext(abspath) == ".go",
+		GoComments: path.Ext(abspath) == ".go",
 		Highlight:  r.FormValue("h"),
 		Selection:  rangeSelection(r.FormValue("s")),
 		Line:       1,
@@ -690,7 +690,7 @@
 	abspath := relpath
 	relpath = relpath[1:] // strip leading slash
 
-	switch pathpkg.Ext(relpath) {
+	switch path.Ext(relpath) {
 	case ".html":
 		p.ServeHTMLDoc(w, r, abspath, relpath)
 		return
@@ -712,8 +712,8 @@
 		if redirect(w, r) {
 			return
 		}
-		index := pathpkg.Join(fsPath, "index.html")
-		if isTextFile(p.Corpus.fs, index) || isTextFile(p.Corpus.fs, pathpkg.Join(fsPath, "index.md")) {
+		index := path.Join(fsPath, "index.html")
+		if isTextFile(p.Corpus.fs, index) || isTextFile(p.Corpus.fs, path.Join(fsPath, "index.md")) {
 			p.ServeHTMLDoc(w, r, index, index)
 			return
 		}
diff --git a/internal/godoc/util.go b/internal/godoc/util.go
index 940cdc2..a113673 100644
--- a/internal/godoc/util.go
+++ b/internal/godoc/util.go
@@ -9,7 +9,7 @@
 
 import (
 	"io/fs"
-	pathpkg "path"
+	"path"
 	"sync"
 	"time"
 	"unicode/utf8"
@@ -69,7 +69,7 @@
 // readable text.
 func isTextFile(fsys fs.FS, filename string) bool {
 	// if the extension is known, use it for decision making
-	if isText, found := textExt[pathpkg.Ext(filename)]; found {
+	if isText, found := textExt[path.Ext(filename)]; found {
 		return isText
 	}