]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modload: use slices.Contains
authorTobias Klauser <tklauser@distanz.ch>
Tue, 8 Oct 2024 08:18:22 +0000 (10:18 +0200)
committerGopher Robot <gobot@golang.org>
Tue, 8 Oct 2024 15:42:57 +0000 (15:42 +0000)
Change-Id: I9d39984b6b15d415189592b592de471f50b43d0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/618495
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/go/internal/modload/load.go

index 7d44bf79e9ea726910f3b57cf4ec3214793bb13e..2a7e5fbe8bd2efa1cc5123753dae819f7417afc7 100644 (file)
@@ -536,14 +536,7 @@ func matchLocalDirs(ctx context.Context, modRoots []string, m *search.Match, rs
                }
 
                modRoot := findModuleRoot(absDir)
-               found := false
-               for _, mainModuleRoot := range modRoots {
-                       if mainModuleRoot == modRoot {
-                               found = true
-                               break
-                       }
-               }
-               if !found && search.InDir(absDir, cfg.GOROOTsrc) == "" && pathInModuleCache(ctx, absDir, rs) == "" {
+               if !slices.Contains(modRoots, modRoot) && search.InDir(absDir, cfg.GOROOTsrc) == "" && pathInModuleCache(ctx, absDir, rs) == "" {
                        m.Dirs = []string{}
                        scope := "main module or its selected dependencies"
                        if inWorkspaceMode() {