Commit 099e002
committed
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 <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>1 parent 0283753 commit 099e002
3 files changed
+47
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 38 | | |
46 | 39 | | |
47 | 40 | | |
| |||
56 | 49 | | |
57 | 50 | | |
58 | 51 | | |
59 | | - | |
| 52 | + | |
60 | 53 | | |
61 | 54 | | |
62 | 55 | | |
| |||
85 | 78 | | |
86 | 79 | | |
87 | 80 | | |
88 | | - | |
| 81 | + | |
89 | 82 | | |
90 | 83 | | |
91 | 84 | | |
| |||
444 | 437 | | |
445 | 438 | | |
446 | 439 | | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | 440 | | |
451 | 441 | | |
452 | 442 | | |
| |||
471 | 461 | | |
472 | 462 | | |
473 | 463 | | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
479 | 489 | | |
480 | 490 | | |
481 | 491 | | |
| |||
500 | 510 | | |
501 | 511 | | |
502 | 512 | | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
507 | 517 | | |
508 | 518 | | |
509 | 519 | | |
510 | | - | |
511 | | - | |
| 520 | + | |
| 521 | + | |
512 | 522 | | |
513 | 523 | | |
514 | 524 | | |
515 | | - | |
516 | | - | |
| 525 | + | |
| 526 | + | |
517 | 527 | | |
518 | 528 | | |
519 | 529 | | |
| |||
525 | 535 | | |
526 | 536 | | |
527 | 537 | | |
528 | | - | |
| 538 | + | |
529 | 539 | | |
530 | 540 | | |
531 | 541 | | |
| |||
536 | 546 | | |
537 | 547 | | |
538 | 548 | | |
539 | | - | |
| 549 | + | |
540 | 550 | | |
541 | 551 | | |
542 | 552 | | |
543 | 553 | | |
544 | 554 | | |
545 | 555 | | |
546 | 556 | | |
547 | | - | |
| 557 | + | |
548 | 558 | | |
549 | 559 | | |
550 | 560 | | |
| |||
790 | 800 | | |
791 | 801 | | |
792 | 802 | | |
793 | | - | |
| 803 | + | |
794 | 804 | | |
795 | 805 | | |
796 | 806 | | |
| |||
934 | 944 | | |
935 | 945 | | |
936 | 946 | | |
937 | | - | |
| 947 | + | |
938 | 948 | | |
939 | 949 | | |
940 | 950 | | |
| |||
944 | 954 | | |
945 | 955 | | |
946 | 956 | | |
947 | | - | |
| 957 | + | |
948 | 958 | | |
949 | 959 | | |
950 | 960 | | |
| |||
963 | 973 | | |
964 | 974 | | |
965 | 975 | | |
966 | | - | |
| 976 | + | |
967 | 977 | | |
968 | 978 | | |
969 | 979 | | |
| |||
980 | 990 | | |
981 | 991 | | |
982 | 992 | | |
983 | | - | |
| 993 | + | |
984 | 994 | | |
985 | 995 | | |
986 | 996 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | 187 | | |
193 | 188 | | |
194 | 189 | | |
| |||
210 | 205 | | |
211 | 206 | | |
212 | 207 | | |
213 | | - | |
| 208 | + | |
214 | 209 | | |
215 | 210 | | |
216 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
928 | 928 | | |
929 | 929 | | |
930 | 930 | | |
931 | | - | |
| 931 | + | |
932 | 932 | | |
933 | | - | |
| 933 | + | |
934 | 934 | | |
935 | 935 | | |
936 | 936 | | |
| |||
950 | 950 | | |
951 | 951 | | |
952 | 952 | | |
953 | | - | |
| 953 | + | |
954 | 954 | | |
955 | 955 | | |
956 | 956 | | |
| |||
0 commit comments