blob: 5fbd890e65f69c214695ffc456e1565e72fc3e82 [file] [log] [blame]
This test demonstrates diagnostics for adding a go.work file.
Quick-fixes change files on disk, so are tested by integration tests.
TODO(rfindley): improve the "cannot find package" import errors.
-- skip --
These diagnostics are no longer produced, because in golang/go#57979
(zero-config gopls) we made gopls function independent of a go.work file.
Preserving this test as we may want to re-enable the code actions go manage
a go.work file.
Note that in go.dev/issue/60584#issuecomment-1622238115, this test was flaky.
However, critical error logic has since been rewritten.
-- a/go.mod --
module mod.com/a
go 1.18
-- a/main.go --
package main //@diag("main", re"add a go.work file")
import "mod.com/a/lib" //@diag("\"mod.com", re"cannot find package")
func main() {
_ = lib.C
}
-- a/lib/lib.go --
package lib //@diag("lib", re"add a go.work file")
const C = "b"
-- b/go.mod --
module mod.com/b
go 1.18
-- b/main.go --
package main //@diag("main", re"add a go.work file")
import "mod.com/b/lib" //@diag("\"mod.com", re"cannot find package")
func main() {
_ = lib.C
}
-- b/lib/lib.go --
package lib //@diag("lib", re"add a go.work file")
const C = "b"