aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres
diff options
context:
space:
mode:
authorNicholas S. Husin <nsh@golang.org>2025-11-04 21:24:43 -0500
committerNicholas Husin <nsh@golang.org>2025-11-05 09:17:17 -0800
commit5cd44362491235c04771c4d8dfcacdd265ada373 (patch)
tree807eb51961e0db4bbcec31f90a7c874642d76d92 /internal/postgres
parent950d5ec0f5e9dbe92b2d1b1301322ea7f75ca1de (diff)
downloadgo-x-pkgsite-5cd44362491235c04771c4d8dfcacdd265ada373.tar.xz
internal/postgres: exclude internal packages when doing shortcut resolution
pkgsite allows users to use a shortcut when looking up std packages. For example, pkg.go.dev/http will resolve to pkg.go.dev/net/http. Currently, this shortcut resolution also works for internal packages (e.g. pkg.go.dev/boring will resolve to pkg.go.dev/crypto/internal/boring), even though Go users would likely not care about internal packages. An unfortunate side-effect of this is that our shortcut resolution does not work for packages which has a similarly-named internal package: pkg.go.dev/synctest does not resolve to pkg.go.dev/testing/synctest as the existence of pkg.go.dev/internal/synctest makes the resolution ambiguous. This change updates our shortcut resolution logic to exclude all internal packages. For golang/go#76136 Change-Id: I83fcf32861079d051bc8dc3be29092480d53f667 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/717840 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> Reviewed-by: Nicholas Husin <husin@google.com>
Diffstat (limited to 'internal/postgres')
-rw-r--r--internal/postgres/stdlib.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/postgres/stdlib.go b/internal/postgres/stdlib.go
index 42063481..60bd58ef 100644
--- a/internal/postgres/stdlib.go
+++ b/internal/postgres/stdlib.go
@@ -17,7 +17,8 @@ import (
// the path must end with "/" + suffix.
//
// We are only interested in actual standard library packages: not commands, which we happen to include
-// in the stdlib module, and not directories (paths that do not contain a package).
+// in the stdlib module; not directories (paths that do not contain a package); and not internal
+// packages.
func (db *DB) GetStdlibPathsWithSuffix(ctx context.Context, suffix string) (paths []string, err error) {
defer derrors.WrapStack(&err, "DB.GetStdlibPaths(ctx, %q)", suffix)
@@ -37,6 +38,8 @@ func (db *DB) GetStdlibPathsWithSuffix(ctx context.Context, suffix string) (path
LIMIT 1)
AND u.name != ''
AND p.path NOT LIKE 'cmd/%'
+ AND p.path NOT LIKE 'internal/%'
+ AND p.path NOT LIKE '%/internal/%'
AND p.path LIKE '%/' || $2
ORDER BY p.path
`