| 1 |
This test checks that gopls works with nested modules, including multiple |
| 2 |
nested modules. |
| 3 |
|
| 4 |
-- main.go -- |
| 5 |
package main |
| 6 |
|
| 7 |
import "fmt" |
| 8 |
|
| 9 |
func main() { |
| 10 |
fmt.Println(mainMsg) //@def("mainMsg", mainMsg) |
| 11 |
fmt.Println(undef) //@diag("undef", re"undefined|undeclared") |
| 12 |
} |
| 13 |
-- main2.go -- |
| 14 |
package main |
| 15 |
|
| 16 |
const mainMsg = "main" //@loc(mainMsg, "mainMsg") |
| 17 |
|
| 18 |
-- mod1/go.mod -- |
| 19 |
module golang.org/lsptests/mod1 |
| 20 |
|
| 21 |
go 1.20 |
| 22 |
|
| 23 |
-- mod1/a/a.go -- |
| 24 |
package a |
| 25 |
|
| 26 |
import ( |
| 27 |
"fmt" |
| 28 |
"golang.org/lsptests/mod1/b" |
| 29 |
) |
| 30 |
|
| 31 |
func _() { |
| 32 |
fmt.Println(b.Msg) //@def("Msg", Msg) |
| 33 |
fmt.Println(undef) //@diag("undef", re"undefined|undeclared") |
| 34 |
} |
| 35 |
|
| 36 |
-- mod1/a/tagged.go -- |
| 37 |
//go:build tag1 |
| 38 |
|
| 39 |
// golang/go#60776: verify that we get an accurate error about build tags |
| 40 |
// here, rather than an inaccurate error suggesting to add a go.work |
| 41 |
// file (which won't help). |
| 42 |
package a //@diag(re`package (a)`, re`excluded due to its build tags`) |
| 43 |
|
| 44 |
-- mod1/b/b.go -- |
| 45 |
package b |
| 46 |
|
| 47 |
const Msg = "1" //@loc(Msg, "Msg") |
| 48 |
|
| 49 |
-- mod2/go.mod -- |
| 50 |
module golang.org/lsptests/mod2 |
| 51 |
|
| 52 |
require golang.org/lsptests/mod1 v0.0.1 |
| 53 |
|
| 54 |
replace golang.org/lsptests/mod1 => ../mod1 |
| 55 |
|
| 56 |
go 1.20 |
| 57 |
|
| 58 |
-- mod2/c/c.go -- |
| 59 |
package c |
| 60 |
|
| 61 |
import ( |
| 62 |
"fmt" |
| 63 |
"golang.org/lsptests/mod1/b" |
| 64 |
) |
| 65 |
|
| 66 |
func _() { |
| 67 |
fmt.Println(b.Msg) //@def("Msg", Msg) |
| 68 |
fmt.Println(undef) //@diag("undef", re"undefined|undeclared") |
| 69 |
} |