mirror of
https://github.com/golang/go
synced 2024-11-05 18:26:10 -07:00
go.tools/cmd/doc: make filename logic separator-agnostic
(Speculative fix for broken cmd/godoc test on Windows.) LGTM=gri R=gri CC=golang-codereviews https://golang.org/cl/90090043
This commit is contained in:
parent
4a9f74ad65
commit
f1247de572
@ -311,17 +311,17 @@ func Run(pta bool, result *Result) {
|
|||||||
errors[err.Pos] = append(errors[err.Pos], err.Msg)
|
errors[err.Pos] = append(errors[err.Pos], err.Msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
var roots, args []string
|
var roots, args []string // roots[i] ends with os.PathSeparator
|
||||||
|
|
||||||
// Enumerate packages in $GOROOT.
|
// Enumerate packages in $GOROOT.
|
||||||
root := runtime.GOROOT() + "/src/pkg/"
|
root := filepath.Join(runtime.GOROOT(), "src", "pkg") + string(os.PathSeparator)
|
||||||
roots = append(roots, root)
|
roots = append(roots, root)
|
||||||
args = allPackages(root)
|
args = allPackages(root)
|
||||||
log.Printf("GOROOT=%s: %s\n", root, args)
|
log.Printf("GOROOT=%s: %s\n", root, args)
|
||||||
|
|
||||||
// Enumerate packages in $GOPATH.
|
// Enumerate packages in $GOPATH.
|
||||||
for i, dir := range filepath.SplitList(build.Default.GOPATH) {
|
for i, dir := range filepath.SplitList(build.Default.GOPATH) {
|
||||||
root := dir + "/src/"
|
root := filepath.Join(dir, "src") + string(os.PathSeparator)
|
||||||
roots = append(roots, root)
|
roots = append(roots, root)
|
||||||
pkgs := allPackages(root)
|
pkgs := allPackages(root)
|
||||||
log.Printf("GOPATH[%d]=%s: %s\n", i, root, pkgs)
|
log.Printf("GOPATH[%d]=%s: %s\n", i, root, pkgs)
|
||||||
@ -524,10 +524,8 @@ func (a linksByStart) Len() int { return len(a) }
|
|||||||
// allPackages returns a new sorted slice of all packages beneath the
|
// allPackages returns a new sorted slice of all packages beneath the
|
||||||
// specified package root directory, e.g. $GOROOT/src/pkg or $GOPATH/src.
|
// specified package root directory, e.g. $GOROOT/src/pkg or $GOPATH/src.
|
||||||
// Derived from from go/ssa/stdlib_test.go
|
// Derived from from go/ssa/stdlib_test.go
|
||||||
|
// root must end with os.PathSeparator.
|
||||||
func allPackages(root string) []string {
|
func allPackages(root string) []string {
|
||||||
if !strings.HasSuffix(root, "/") {
|
|
||||||
root += "/"
|
|
||||||
}
|
|
||||||
var pkgs []string
|
var pkgs []string
|
||||||
filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||||
if info == nil {
|
if info == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user