aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata
diff options
context:
space:
mode:
authorIan Alexander <jitsu@google.com>2025-11-11 13:50:51 -0500
committerIan Alexander <jitsu@google.com>2025-11-13 09:54:28 -0800
commit099e0027bd7d282c400b1f5930d19a4652a265eb (patch)
tree420a31017b37ad1bbff2d54f80ba6846d164667b /src/runtime/testdata
parent028375323f39b2d59bae0abfe20ba187c42bcf16 (diff)
downloadgo-099e0027bd7d282c400b1f5930d19a4652a265eb.tar.xz
cmd/go/internal/modfetch: consolidate global vars
This commit conslidates global variables represeting the current modfetch state into a single variable in preparation for injection via the rsc.io/rf tool. This commit is part of the larger effort to eliminate global module loader state. [git-generate] cd src/cmd/go/internal/modfetch rf ' add State func NewState() *State {\ s := new(State)\ s.lookupCache = new(par.Cache[lookupCacheKey, Repo])\ s.downloadCache = new(par.ErrCache[module.Version, string])\ return s\ } add State var ModuleFetchState *State = NewState() mv State.goSumFile State.GoSumFile add State:/^[[:space:]]*GoSumFile /-0 // path to go.sum; set by package modload ex { GoSumFile -> ModuleFetchState.GoSumFile } mv State.workspaceGoSumFiles State.WorkspaceGoSumFiles add State:/^[[:space:]]*WorkspaceGoSumFiles /-0 // path to module go.sums in workspace; set by package modload ex { WorkspaceGoSumFiles -> ModuleFetchState.WorkspaceGoSumFiles } add State:/^[[:space:]]*lookupCache /-0 // The Lookup cache is used cache the work done by Lookup.\ // It is important that the global functions of this package that access it do not\ // do so after they return. add State:/^[[:space:]]*downloadCache /-0 // The downloadCache is used to cache the operation of downloading a module to disk\ // (if it'\\\''s not already downloaded) and getting the directory it was downloaded to.\ // It is important that downloadCache must not be accessed by any of the exported\ // functions of this package after they return, because it can be modified by the\ // non-thread-safe SetState function. add State:/^[[:space:]]*downloadCache.*$/ // version → directory; ex { lookupCache -> ModuleFetchState.lookupCache downloadCache -> ModuleFetchState.downloadCache } rm 'lookupCache' rm 'downloadCache' ' for dir in modload ; do cd ../${dir} rf ' ex { import "cmd/go/internal/modfetch" modfetch.GoSumFile -> modfetch.ModuleFetchState.GoSumFile modfetch.WorkspaceGoSumFiles -> modfetch.ModuleFetchState.WorkspaceGoSumFiles } ' done cd ../modfetch rf ' rm GoSumFile rm WorkspaceGoSumFiles ' Change-Id: Iaa0f8a40192127457a539120eb94337940cb8d4a Reviewed-on: https://go-review.googlesource.com/c/go/+/719700 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/testdata')
0 files changed, 0 insertions, 0 deletions