[tools] gopls/internal/golang/completion: skip duplicate std/ packages

1 view
Skip to first unread message

Nhan Nguyen (Gerrit)

unread,
Dec 18, 2025, 10:58:06 PM (16 hours ago) Dec 18
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Nhan Nguyen has uploaded the change for review

Commit message

gopls/internal/golang/completion: skip duplicate std/ packages

Skip packages with "std/" prefix in completion candidates since they
are duplicates of standard library packages already handled elsewhere.

For example, "maps" and "std/maps" refer to the same package, but both
would appear in completions. Now we skip "std/maps" to avoid duplicates.

Fixes golang/go#75310
Change-Id: Ie50d06db0e4998fbd0d6a0544a04d7a3b2b07a57

Change diff

diff --git a/gopls/internal/golang/completion/completion.go b/gopls/internal/golang/completion/completion.go
index f6d2277..d3fca7f 100644
--- a/gopls/internal/golang/completion/completion.go
+++ b/gopls/internal/golang/completion/completion.go
@@ -1922,6 +1922,11 @@
if ignoreUnimportedCompletion(&pkg) {
return
}
+ // Skip standard library module paths (e.g., "std/maps") since they are
+ // duplicates of stdlib packages. See golang/go#75310.
+ if strings.HasPrefix(pkg.StmtInfo.ImportPath, "std/") {
+ return
+ }
mu.Lock()
defer mu.Unlock()
if _, ok := seen[pkg.IdentName]; ok {
diff --git a/gopls/internal/golang/completion/unimported.go b/gopls/internal/golang/completion/unimported.go
index 53350ef..85576de 100644
--- a/gopls/internal/golang/completion/unimported.go
+++ b/gopls/internal/golang/completion/unimported.go
@@ -311,6 +311,12 @@
got := make([]CompletionItem, 0, lx)
pattern := strings.ToLower(prefix)
for _, cand := range cands {
+ // Skip standard library module paths (e.g., "std/maps") since they are
+ // duplicates of packages already handled by stdlibMatches.
+ // See golang/go#75310.
+ if strings.HasPrefix(cand.ImportPath, "std/") {
+ continue
+ }
if !usefulCompletion(cand.Name, pattern) {
continue
}

Change information

Files:
  • M gopls/internal/golang/completion/completion.go
  • M gopls/internal/golang/completion/unimported.go
Change size: S
Delta: 2 files changed, 11 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Ie50d06db0e4998fbd0d6a0544a04d7a3b2b07a57
Gerrit-Change-Number: 731380
Gerrit-PatchSet: 1
Gerrit-Owner: Nhan Nguyen <nhan...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Nhan Nguyen (Gerrit)

unread,
Dec 18, 2025, 11:10:55 PM (16 hours ago) Dec 18
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Nhan Nguyen and Xie Yuchen

Nhan Nguyen uploaded new patchset

Nhan Nguyen uploaded patch set #2 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Nhan Nguyen
  • Xie Yuchen
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Ie50d06db0e4998fbd0d6a0544a04d7a3b2b07a57
Gerrit-Change-Number: 731380
Gerrit-PatchSet: 2
Gerrit-Owner: Nhan Nguyen <nhan...@gmail.com>
Gerrit-Reviewer: Xie Yuchen <xieyu...@gmail.com>
Gerrit-Attention: Nhan Nguyen <nhan...@gmail.com>
Gerrit-Attention: Xie Yuchen <xieyu...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages