Skip to content

Commit 8bac6fa

Browse files
committed
[gopls-release-branch.0.4] 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]> (cherry picked from commit 8afe7e0) Reviewed-on: https://go-review.googlesource.com/c/tools/+/245541
1 parent dc9b9f8 commit 8bac6fa

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
@@ -436,8 +436,12 @@ func missingModuleErrors(ctx context.Context, fset *token.FileSet, modMapper *pr
436436
for _, pkg := range pkgs {
437437
missingPkgs := map[string]*modfile.Require{}
438438
for _, imp := range pkg.Imports() {
439-
if req, ok := missingMods[imp.PkgPath()]; ok {
439+
found := func(req *modfile.Require) {
440440
missingPkgs[imp.PkgPath()] = req
441+
matchedMissingMods[req] = struct{}{}
442+
}
443+
if req, ok := missingMods[imp.PkgPath()]; ok {
444+
found(req)
441445
break
442446
}
443447
// If the import is a package of the dependency, then add the
@@ -457,8 +461,7 @@ func missingModuleErrors(ctx context.Context, fset *token.FileSet, modMapper *pr
457461
}
458462
}
459463
if req, ok := missingMods[match]; ok {
460-
missingPkgs[imp.PkgPath()] = req
461-
matchedMissingMods[req] = struct{}{}
464+
found(req)
462465
}
463466
}
464467
if len(missingPkgs) > 0 {

0 commit comments

Comments
 (0)