aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres
diff options
context:
space:
mode:
authorHana Kim <hyangah@gmail.com>2026-03-05 22:47:31 -0500
committerHyang-Ah Hana Kim <hyangah@gmail.com>2026-03-26 14:11:32 -0700
commit98258ff769bbca6f3d004ce80fabf5bff8f1136c (patch)
tree1ff3dccebdfc2df17009088688a1575383f68a42 /internal/postgres
parent34edebc0803b121acd1cbf363eef074e0a13ab6d (diff)
downloadgo-x-pkgsite-98258ff769bbca6f3d004ce80fabf5bff8f1136c.tar.xz
all: run go fix -slicescontains
Change-Id: I14479d9e612dfa7eed9188206746af5b51c10201 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/753428 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/postgres')
-rw-r--r--internal/postgres/search.go8
-rw-r--r--internal/postgres/symbolsearch.go7
2 files changed, 5 insertions, 10 deletions
diff --git a/internal/postgres/search.go b/internal/postgres/search.go
index bdc2c30d..f9ab60de 100644
--- a/internal/postgres/search.go
+++ b/internal/postgres/search.go
@@ -8,6 +8,7 @@ import (
"context"
"database/sql"
"fmt"
+ "slices"
"sort"
"strings"
"time"
@@ -1006,12 +1007,7 @@ func GeneratePathTokens(packagePath string) []string {
// isInternalPackage reports whether the path represents an internal directory.
func isInternalPackage(path string) bool {
- for _, p := range strings.Split(path, "/") {
- if p == "internal" {
- return true
- }
- }
- return false
+ return slices.Contains(strings.Split(path, "/"), "internal")
}
// UpsertSearchDocumentWithImportedByCount is the same as UpsertSearchDocument,
diff --git a/internal/postgres/symbolsearch.go b/internal/postgres/symbolsearch.go
index f1a273e6..9373c92c 100644
--- a/internal/postgres/symbolsearch.go
+++ b/internal/postgres/symbolsearch.go
@@ -9,6 +9,7 @@ import (
"database/sql"
"errors"
"fmt"
+ "slices"
"sort"
"strings"
@@ -299,12 +300,10 @@ func splitPackageAndSymbolNames(q string) (pkgName string, symbolName string, er
if len(parts) != 2 && len(parts) != 3 {
return "", "", derrors.NotFound
}
- for _, p := range parts {
+ if slices.Contains(parts, "") {
// Handle cases where we have odd dot placement, such as .Foo or
// Foo..
- if p == "" {
- return "", "", derrors.NotFound
- }
+ return "", "", derrors.NotFound
}
return parts[0], strings.Join(parts[1:], "."), nil
}