Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If GO111MODULE=on but there's no go.mod, GOMOD will be set to /dev/null or NUL and there will be no main module. goimports should handle this case roughly the same way the go command does. Fixes #30855 Change-Id: I6fbf4c056000db5abd8788a6014ae5f13b1c8cd4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/167860 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Ian Cottrell <iancottrell@google.com>
- Loading branch information
Showing
3 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// +build go1.12 | ||
|
||
package imports | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// Tests that we handle GO111MODULE=on with no go.mod file. See #30855. | ||
func TestNoMainModule(t *testing.T) { | ||
mt := setup(t, ` | ||
-- x.go -- | ||
package x | ||
`, "") | ||
defer mt.cleanup() | ||
if _, err := mt.env.invokeGo("mod", "download", "rsc.io/quote@v1.5.1"); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
mt.assertScanFinds("rsc.io/quote", "quote") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters