Skip to content

Commit

Permalink
cmd/doc: show the true import path rather than "."
Browse files Browse the repository at this point in the history
Change-Id: I7b15c027c15eefc2a004eb61491e828a7fbefc54
Reviewed-on: https://go-review.googlesource.com/9513
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
robpike committed Apr 29, 2015
1 parent 632778c commit 1ab60c2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/cmd/doc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func parseArgs() (*build.Package, string, string) {
usage()
case 0:
// Easy: current directory.
return importDir("."), "", ""
return importDir(pwd()), "", ""
case 1:
// Done below.
case 2:
Expand Down Expand Up @@ -156,7 +156,7 @@ func parseArgs() (*build.Package, string, string) {
log.Fatalf("no such package %s", arg[0:period])
}
// Guess it's a symbol in the current directory.
return importDir("."), "", arg
return importDir(pwd()), "", arg
}

// importDir is just an error-catching wrapper for build.ImportDir.
Expand Down Expand Up @@ -285,3 +285,12 @@ func pathFor(root, pkg string) (result string) {
filepath.Walk(root, visit)
return "" // Call to panic above sets the real value.
}

// pwd returns the current directory.
func pwd() string {
wd, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
return wd
}

0 comments on commit 1ab60c2

Please sign in to comment.