Skip to content

Commit 8afe7e0

Browse files
committed
internal/lsp: don't show diagnostic in go.mod for direct dependencies
Fixes golang/go#40470. Change-Id: I4831b837e6db5cc344c20480abde1e688ddab0dc Reviewed-on: https://go-review.googlesource.com/c/tools/+/245537 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Cottrell <[email protected]>
1 parent 449c585 commit 8afe7e0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/lsp/cache/mod_tidy.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,12 @@ func missingModuleErrors(ctx context.Context, snapshot *snapshot, modMapper *pro
424424
for _, pkg := range pkgs {
425425
missingPkgs := map[string]*modfile.Require{}
426426
for _, imp := range pkg.Imports() {
427-
if req, ok := missingMods[imp.PkgPath()]; ok {
427+
found := func(req *modfile.Require) {
428428
missingPkgs[imp.PkgPath()] = req
429+
matchedMissingMods[req] = struct{}{}
430+
}
431+
if req, ok := missingMods[imp.PkgPath()]; ok {
432+
found(req)
429433
break
430434
}
431435
// If the import is a package of the dependency, then add the
@@ -445,8 +449,7 @@ func missingModuleErrors(ctx context.Context, snapshot *snapshot, modMapper *pro
445449
}
446450
}
447451
if req, ok := missingMods[match]; ok {
448-
missingPkgs[imp.PkgPath()] = req
449-
matchedMissingMods[req] = struct{}{}
452+
found(req)
450453
}
451454
}
452455
if len(missingPkgs) > 0 {

0 commit comments

Comments
 (0)