Skip to content

Commit 3ff8ce0

Browse files
committed
Remove getPackageRoot and use . instead
1 parent 04e49fa commit 3ff8ce0

File tree

5 files changed

+5
-109
lines changed

5 files changed

+5
-109
lines changed

loader/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ func (p *Package) importRecursively(includeTests bool) error {
477477
if importedPkg.Importing {
478478
return &ImportCycleError{[]string{p.ImportPath, importedPkg.ImportPath}, p.ImportPos[to]}
479479
}
480-
err = importedPkg.importRecursively(includeTests)
480+
err = importedPkg.importRecursively(false)
481481
if err != nil {
482482
if err, ok := err.(*ImportCycleError); ok {
483483
err.Packages = append([]string{p.ImportPath}, err.Packages...)

main.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,11 @@ func main() {
683683
err := Run(flag.Arg(0), *target, config)
684684
handleCompilerError(err)
685685
case "test":
686-
pkgRoot, err := getPackageRoot()
687-
if err != nil {
688-
fmt.Fprintln(os.Stderr, err)
689-
os.Exit(1)
686+
pkgRoot := "."
687+
if flag.NArg() == 1 {
688+
pkgRoot = flag.Arg(0)
690689
}
691-
err = Test(pkgRoot, *target, config)
690+
err := Test(pkgRoot, *target, config)
692691
handleCompilerError(err)
693692
case "clean":
694693
// remove cache directory

target.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -303,30 +303,6 @@ func getGopath() string {
303303
return filepath.Join(home, "go")
304304
}
305305

306-
func getPackageRoot() (string, error) {
307-
wd, err := os.Getwd()
308-
if err != nil {
309-
return "", err
310-
}
311-
if rwd, err := filepath.EvalSymlinks(wd); err == nil {
312-
wd = rwd
313-
}
314-
315-
// TODO: This assumes a single gopath
316-
// A more robust solution can be found in golang/dep, and probably golang/go.
317-
// See https://github.com/golang/dep/blob/9227ca64191910befb850cfc4dc85fd93e12ba68/context.go#L256
318-
gopath := getGopath()
319-
if rgopath, err := filepath.EvalSymlinks(gopath); err == nil {
320-
gopath = rgopath
321-
}
322-
323-
src := filepath.Join(gopath, "src") + string(os.PathSeparator)
324-
if strings.HasPrefix(wd, src) {
325-
return strings.TrimPrefix(wd, src), nil
326-
}
327-
return "", fmt.Errorf("could not determine the package root from the current directory %q and gopath %q", wd, gopath)
328-
}
329-
330306
func getHomeDir() string {
331307
u, err := user.Current()
332308
if err != nil {

target_test.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

test.go

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)