aboutsummaryrefslogtreecommitdiff
path: root/internal/fetch
diff options
context:
space:
mode:
authorEthan Lee <ethanalee@google.com>2026-03-25 18:18:15 +0000
committerGopher Robot <gobot@golang.org>2026-03-26 14:02:59 -0700
commit34edebc0803b121acd1cbf363eef074e0a13ab6d (patch)
tree72af43d88fd8e6c83d93beae0dba3cc62395e70d /internal/fetch
parent8378ff811c1228f6a50808cb7557e6c08782205a (diff)
downloadgo-x-pkgsite-34edebc0803b121acd1cbf363eef074e0a13ab6d.tar.xz
internal: consolidate build context and unit resolution logic
- Centralize logic for resolving units and selecting the best matching build context. - New helpers MatchingBuildContext, SortedBuildContexts provide a consistent, efficient approach to build context selection. - DocumentationForBuildContext now finds the best match based on precdence rules rather than just returning the first match. - A new getUnitContext helper resolves unit metadata and the best build context in a single query. - GetSymbols and GetUnit are now both optimized to use pre-resolved IDs, simplifying their queries and removing redundant joins. - Replaced redundant matchingDoc functions in fetchdatasource and fakedatasource. Change-Id: I9207d3bfe03404483c816090a0b99666f14a36e3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/759162 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ethan Lee <ethanalee@google.com>
Diffstat (limited to 'internal/fetch')
-rw-r--r--internal/fetch/unit.go6
1 files changed, 1 insertions, 5 deletions
diff --git a/internal/fetch/unit.go b/internal/fetch/unit.go
index e0c9c6f3..301d2b7d 100644
--- a/internal/fetch/unit.go
+++ b/internal/fetch/unit.go
@@ -6,7 +6,6 @@ package fetch
import (
"path"
- "sort"
"golang.org/x/pkgsite/internal"
"golang.org/x/pkgsite/internal/licenses"
@@ -45,10 +44,7 @@ func moduleUnit(modulePath string, unitMeta *internal.UnitMeta,
for _, d := range unit.Documentation {
bcs = append(bcs, internal.BuildContext{GOOS: d.GOOS, GOARCH: d.GOARCH})
}
- sort.Slice(bcs, func(i, j int) bool {
- return internal.CompareBuildContexts(bcs[i], bcs[j]) < 0
- })
- unit.BuildContexts = bcs
+ unit.BuildContexts = internal.SortedBuildContexts(bcs)
}
return unit
}