From 70e5087371296e2632232f4a3a795f124c73baf3 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Thu, 9 Apr 2026 08:10:31 -0400 Subject: 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 Reviewed-by: Ethan Lee kokoro-CI: kokoro --- internal/testing/fakedatasource/fakedatasource.go | 7 ++----- 1 file 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} -- cgit v1.3