mirror of
https://github.com/golang/go
synced 2024-11-06 04:26:11 -07:00
757ca719ca
For various reasons we need an internal-facing imports API. Move imports to internal/imports, leaving behind a small wrapper package. The wrapper package captures the globals at time of call into the options struct. Also converts the last goimports tests to use the test helpers, and fixes go/packages in module mode to work with empty modules, which was necessary to get those last tests converted. Change-Id: Ib1212c67908741a1800b992ef1935d563c6ade32 Reviewed-on: https://go-review.googlesource.com/c/tools/+/175437 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
22 lines
386 B
Go
22 lines
386 B
Go
// +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")
|
|
}
|