aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2026-04-09 08:10:31 -0400
committerJonathan Amsterdam <jba@google.com>2026-04-10 14:29:59 -0700
commit70e5087371296e2632232f4a3a795f124c73baf3 (patch)
tree5434ea20af040c8fa4a532cab1e5b0a76a4dfe68
parentf7bc24a6530b92e33af894238e4f992d6e350f06 (diff)
downloadgo-x-pkgsite-70e5087371296e2632232f4a3a795f124c73baf3.tar.xz
internal/testing/fakedatasource: improve doc
This was inadvertently left out of an earlier CL. Change-Id: I5ec5d82c9fa2efcc27c076360cb50097c86655d7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/764821 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ethan Lee <ethanalee@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
-rw-r--r--internal/testing/fakedatasource/fakedatasource.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/internal/testing/fakedatasource/fakedatasource.go b/internal/testing/fakedatasource/fakedatasource.go
index e621e2e8..35814132 100644
--- a/internal/testing/fakedatasource/fakedatasource.go
+++ b/internal/testing/fakedatasource/fakedatasource.go
@@ -135,9 +135,8 @@ func (ds *FakeDataSource) GetUnit(ctx context.Context, um *internal.UnitMeta, fi
if u == nil {
return nil, fmt.Errorf("import path %s not found in module %s: %w", um.Path, um.ModulePath, derrors.NotFound)
}
-
- // Clone the unit, because we might modify it.
- // A shallow copy suffices.
+ // Since we cache the module and its units, we have to copy this unit before we modify it.
+ // It can be a shallow copy, since we're only modifying the Unit.Documentation field.
u2 := *u
// Return licenses only if requested.
if fields&internal.WithLicenses == 0 {
@@ -149,8 +148,6 @@ func (ds *FakeDataSource) GetUnit(ctx context.Context, um *internal.UnitMeta, fi
u2.Imports = nil
}
// Return only the Documentation matching the given BuildContext, if any.
- // Since we cache the module and its units, we have to copy this unit before we modify it.
- // It can be a shallow copy, since we're only modifying the Unit.Documentation field.
if fields&internal.WithDocsSource != 0 {
if d := internal.DocumentationForBuildContext(u.Documentation, bc); d != nil {
u2.Documentation = []*internal.Documentation{d}