| 1 |
This test demonstrates diagnostics for adding a go.work file. |
| 2 |
|
| 3 |
Quick-fixes change files on disk, so are tested by integration tests. |
| 4 |
|
| 5 |
TODO(rfindley): improve the "cannot find package" import errors. |
| 6 |
|
| 7 |
-- skip -- |
| 8 |
These diagnostics are no longer produced, because in golang/go#57979 |
| 9 |
(zero-config gopls) we made gopls function independent of a go.work file. |
| 10 |
Preserving this test as we may want to re-enable the code actions go manage |
| 11 |
a go.work file. |
| 12 |
|
| 13 |
Note that in go.dev/issue/60584#issuecomment-1622238115, this test was flaky. |
| 14 |
However, critical error logic has since been rewritten. |
| 15 |
|
| 16 |
-- a/go.mod -- |
| 17 |
module mod.com/a |
| 18 |
|
| 19 |
go 1.18 |
| 20 |
|
| 21 |
-- a/main.go -- |
| 22 |
package main //@diag("main", re"add a go.work file") |
| 23 |
|
| 24 |
import "mod.com/a/lib" //@diag("\"mod.com", re"cannot find package") |
| 25 |
|
| 26 |
func main() { |
| 27 |
_ = lib.C |
| 28 |
} |
| 29 |
|
| 30 |
-- a/lib/lib.go -- |
| 31 |
package lib //@diag("lib", re"add a go.work file") |
| 32 |
|
| 33 |
const C = "b" |
| 34 |
-- b/go.mod -- |
| 35 |
module mod.com/b |
| 36 |
|
| 37 |
go 1.18 |
| 38 |
|
| 39 |
-- b/main.go -- |
| 40 |
package main //@diag("main", re"add a go.work file") |
| 41 |
|
| 42 |
import "mod.com/b/lib" //@diag("\"mod.com", re"cannot find package") |
| 43 |
|
| 44 |
func main() { |
| 45 |
_ = lib.C |
| 46 |
} |
| 47 |
|
| 48 |
-- b/lib/lib.go -- |
| 49 |
package lib //@diag("lib", re"add a go.work file") |
| 50 |
|
| 51 |
const C = "b" |