[tools] gopls/internal/server: modify checkGoModDeps condition

2 views
Skip to first unread message

Ethan Lee (Gerrit)

unread,
Dec 15, 2025, 2:44:02 PM (24 hours ago) Dec 15
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Ethan Lee has uploaded the change for review

Commit message

gopls/internal/server: modify checkGoModDeps condition

- Use slices.IndexFunc to check if a file has been created or modified
once.
Change-Id: Ia3df152240c36843507936eddf16a560c82b5a4b

Change diff

diff --git a/gopls/internal/server/text_synchronization.go b/gopls/internal/server/text_synchronization.go
index 6c73800..8fbef8b 100644
--- a/gopls/internal/server/text_synchronization.go
+++ b/gopls/internal/server/text_synchronization.go
@@ -10,6 +10,7 @@
"errors"
"fmt"
"path/filepath"
+ "slices"
"strings"
"sync"

@@ -254,13 +255,11 @@
// to their files.
modifications = s.session.ExpandModificationsToDirectories(ctx, modifications)

- for _, m := range modifications {
- // TODO: also handle go.work changes as well.
- if strings.HasSuffix(m.URI.Path(), "go.mod") {
- if m.Action == file.Create || m.Action == file.Change {
- s.checkGoModDeps(ctx, m.URI)
- }
- }
+ // TODO: also handle go.work changes as well.
+ if idx := slices.IndexFunc(modifications, func(m file.Modification) bool {
+ return strings.HasSuffix(m.URI.Path(), "go.mod") && (m.Action == file.Create || m.Action == file.Change)
+ }); idx != -1 {
+ s.checkGoModDeps(ctx, modifications[idx].URI)
}

viewsToDiagnose, err := s.session.DidModifyFiles(ctx, modifications)

Change information

Files:
  • M gopls/internal/server/text_synchronization.go
Change size: S
Delta: 1 file changed, 6 insertions(+), 7 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: Ia3df152240c36843507936eddf16a560c82b5a4b
Gerrit-Change-Number: 730163
Gerrit-PatchSet: 1
Gerrit-Owner: Ethan Lee <etha...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Ethan Lee (Gerrit)

unread,
Dec 15, 2025, 2:44:42 PM (24 hours ago) Dec 15
to goph...@pubsubhelper.golang.org, Hongxiang Jiang, golang-co...@googlegroups.com
Attention needed from Hongxiang Jiang

Ethan Lee voted

Auto-Submit+1
Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Hongxiang Jiang
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: comment
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Ia3df152240c36843507936eddf16a560c82b5a4b
Gerrit-Change-Number: 730163
Gerrit-PatchSet: 1
Gerrit-Owner: Ethan Lee <etha...@google.com>
Gerrit-Reviewer: Ethan Lee <etha...@google.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Comment-Date: Mon, 15 Dec 2025 19:44:39 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 15, 2025, 6:43:27 PM (20 hours ago) Dec 15
to Ethan Lee, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
Attention needed from Ethan Lee

Hongxiang Jiang added 1 comment

File gopls/internal/server/text_synchronization.go
Line 259, Patchset 1 (Latest): if idx := slices.IndexFunc(modifications, func(m file.Modification) bool {
Hongxiang Jiang . unresolved

I'm very sorry I was wrong about it previously. I forgot the fact that you have to run `s.checkGoModDeps()` with the URI.

In this case, we can keep using the for loop

```
var uris map[protocol.URI]struct{}
for ... {
if isModeFile && (isCreate or isChange) {
uris[uri] = struct{}
}

}
for .. := range uri {
s.checkGoModDeps(ctx, uri)
}
```

This would de-duplicate.

Open in Gerrit

Related details

Attention is currently required from:
  • Ethan Lee
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: tools
    Gerrit-Branch: master
    Gerrit-Change-Id: Ia3df152240c36843507936eddf16a560c82b5a4b
    Gerrit-Change-Number: 730163
    Gerrit-PatchSet: 1
    Gerrit-Owner: Ethan Lee <etha...@google.com>
    Gerrit-Reviewer: Ethan Lee <etha...@google.com>
    Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Attention: Ethan Lee <etha...@google.com>
    Gerrit-Comment-Date: Mon, 15 Dec 2025 23:43:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Hongxiang Jiang (Gerrit)

    unread,
    Dec 15, 2025, 9:15:14 PM (17 hours ago) Dec 15
    to Ethan Lee, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Ethan Lee

    Hongxiang Jiang voted Code-Review+1

    Code-Review+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ethan Lee
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: tools
      Gerrit-Branch: master
      Gerrit-Change-Id: Ia3df152240c36843507936eddf16a560c82b5a4b
      Gerrit-Change-Number: 730163
      Gerrit-PatchSet: 1
      Gerrit-Owner: Ethan Lee <etha...@google.com>
      Gerrit-Reviewer: Ethan Lee <etha...@google.com>
      Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Attention: Ethan Lee <etha...@google.com>
      Gerrit-Comment-Date: Tue, 16 Dec 2025 02:15:07 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Ethan Lee (Gerrit)

      unread,
      11:14 AM (3 hours ago) 11:14 AM
      to goph...@pubsubhelper.golang.org, Hongxiang Jiang, Go LUCI, golang-co...@googlegroups.com
      Attention needed from Hongxiang Jiang

      Ethan Lee voted and added 1 comment

      Votes added by Ethan Lee

      Commit-Queue+1

      1 comment

      File gopls/internal/server/text_synchronization.go
      Line 259, Patchset 1 (Latest): if idx := slices.IndexFunc(modifications, func(m file.Modification) bool {
      Hongxiang Jiang . resolved

      I'm very sorry I was wrong about it previously. I forgot the fact that you have to run `s.checkGoModDeps()` with the URI.

      In this case, we can keep using the for loop

      ```
      var uris map[protocol.URI]struct{}
      for ... {
      if isModeFile && (isCreate or isChange) {
      uris[uri] = struct{}
      }

      }
      for .. := range uri {
      s.checkGoModDeps(ctx, uri)
      }
      ```

      This would de-duplicate.

      Ethan Lee

      Sure, that would handle the scenario in which there are multiple go.mod files in the workspace that have changed.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Hongxiang Jiang
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        • requirement satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: tools
        Gerrit-Branch: master
        Gerrit-Change-Id: Ia3df152240c36843507936eddf16a560c82b5a4b
        Gerrit-Change-Number: 730163
        Gerrit-PatchSet: 1
        Gerrit-Owner: Ethan Lee <etha...@google.com>
        Gerrit-Reviewer: Ethan Lee <etha...@google.com>
        Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
        Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
        Gerrit-Comment-Date: Tue, 16 Dec 2025 16:14:16 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Hongxiang Jiang <hxj...@golang.org>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Ethan Lee (Gerrit)

        unread,
        11:15 AM (3 hours ago) 11:15 AM
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Ethan Lee and Hongxiang Jiang

        Ethan Lee uploaded new patchset

        Ethan Lee uploaded patch set #2 to this change.
        Following approvals got outdated and were removed:
        • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Ethan Lee
        • Hongxiang Jiang
        Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement satisfiedNo-Unresolved-Comments
          • requirement 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: Ia3df152240c36843507936eddf16a560c82b5a4b
          Gerrit-Change-Number: 730163
          Gerrit-PatchSet: 2
          Gerrit-Owner: Ethan Lee <etha...@google.com>
          Gerrit-Reviewer: Ethan Lee <etha...@google.com>
          Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
          Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
          Gerrit-Attention: Ethan Lee <etha...@google.com>
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Ethan Lee (Gerrit)

          unread,
          11:16 AM (3 hours ago) 11:16 AM
          to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
          Attention needed from Ethan Lee and Hongxiang Jiang

          Ethan Lee uploaded new patchset

          Ethan Lee uploaded patch set #3 to this change.
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Ethan Lee
          • Hongxiang Jiang
          Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement satisfiedNo-Unresolved-Comments
          • requirement 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: Ia3df152240c36843507936eddf16a560c82b5a4b
          Gerrit-Change-Number: 730163
          Gerrit-PatchSet: 3
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Ethan Lee (Gerrit)

          unread,
          11:16 AM (3 hours ago) 11:16 AM
          to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
          Attention needed from Ethan Lee and Hongxiang Jiang

          Ethan Lee uploaded new patchset

          Ethan Lee uploaded patch set #4 to this change.
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Ethan Lee
          • Hongxiang Jiang
          Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement satisfiedNo-Unresolved-Comments
          • requirement 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: Ia3df152240c36843507936eddf16a560c82b5a4b
          Gerrit-Change-Number: 730163
          Gerrit-PatchSet: 4
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages