]> Cypherpunks repositories - gostls13.git/commit
cmd/go: fix modload infinite directory loop
authorDaniel Martí <mvdan@mvdan.cc>
Sun, 19 Aug 2018 12:53:57 +0000 (13:53 +0100)
committerRuss Cox <rsc@golang.org>
Tue, 21 Aug 2018 01:44:48 +0000 (01:44 +0000)
commit692307aa839252285ebb91b4072e3c05ff554341
treeabcc4f8bb748f5990e5fb0ffc7490b1f5068be93
parent539ff607a70bb6f7f12b1bca6b365ab0af448fcf
cmd/go: fix modload infinite directory loop

It is possible to enter the parent-walking directory loop in a way that
it will loop forever - if mdir is empty, and d reaches ".". To avoid
this, make sure that the 'd = filepath.Dir(d)' step only happens if the
parent directory is actually different than the current directory.

This fixes some of the tests like TestImport/golang.org_x_net_context,
which were never finishing before.

While at it, also fix TestImport/golang.org_x_net, which seems to have
the wrong expected error. The root of the x/net repo doesn't have a
go.mod file, nor is part of a module itself, so it seems like the
expected error should reflect that.

After these two changes, 'go test cmd/go/internal/modload' passes on my
linux/amd64 machine.

Fixes #27080.

Change-Id: Ie8bab0f9fbc9f447844cbbc64117420d9087db1b
Reviewed-on: https://go-review.googlesource.com/129778
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/go/internal/modload/import.go
src/cmd/go/internal/modload/import_test.go