Skip to content

Commit 36086e8

Browse files
committed
cmd/go: create temporary cleanup script
This is a large series of sed commands to cleanup after successful use of the `rf inject` command. This script will be used to refactor the codebase to eliminate global state within the module loader. Once that effort is complete, this script will be removed. This commit is part of the overall effort to eliminate global modloader state. Change-Id: If04926b5ca5b7230f91ac98fe4a82c20ef5f73ee Reviewed-on: https://go-review.googlesource.com/c/go/+/709978 Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Bypass: Ian Alexander <jitsu@google.com> Commit-Queue: Ian Alexander <jitsu@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
1 parent 7056c71 commit 36086e8

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/cmd/go/internal/rf-cleanup.zsh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env zsh
2+
3+
set -eu -o pipefail
4+
5+
# This is a large series of sed commands to cleanup after successful use of the
6+
# `rf inject` command. This script will be used to refactor the codebase to
7+
# eliminate global state within the module loader. Once that effort is
8+
# complete, this script will be removed.
9+
10+
find . -name '*.go' -exec \
11+
sed -i '
12+
#
13+
# CompileAction does not use loaderstate.
14+
#
15+
s/CompileAction(loaderstate[^ ]* \*modload.State, /CompileAction(/g
16+
s/CompileAction(modload.LoaderState[^,]*, /CompileAction(/g
17+
s/CompileAction(loaderstate[^,]*, /CompileAction(/g
18+
#
19+
# cgoAction does not use loaderstate.
20+
#
21+
s/cgoAction(loaderstate \*modload\.State, /cgoAction(/g
22+
s/cgoAction(loaderstate, /cgoAction(/g
23+
s/cgoAction(loaderstate_, /cgoAction(/g
24+
#
25+
# Remove redundant mentions of LoaderState from function call sites.
26+
#
27+
s/(modload\.LoaderState_*, loaderstate,/(loaderstate,/g
28+
s/(modload\.LoaderState_*, moduleLoaderState,/(moduleLoaderState,/g
29+
s/(modload\.LoaderState_*, modload\.LoaderState/(modload.LoaderState/g
30+
s/(modload\.LoaderState_*, loaderstate,/(loaderstate,/g
31+
s/(modload\.LoaderState_*, moduleLoaderState,/(moduleLoaderState,/g
32+
s/(modload\.LoaderState_*, modload\.LoaderState,/(modload.LoaderState,/g
33+
s/(loaderstate_* \*modload.State, loaderstate \*modload.State/(loaderstate *modload.State/g
34+
s/(loaderstate_* \*State, loaderstate \*State/(loaderstate *State/g
35+
s/(loaderstate_*, loaderstate,/(loaderstate,/g
36+
s/(LoaderState_*, loaderstate,/(loaderstate,/g
37+
s/(LoaderState_*, loaderState,/(loaderState,/g
38+
s/(LoaderState_*, LoaderState,/(LoaderState,/g
39+
s/(LoaderState_*, LoaderState,/(LoaderState,/g
40+
s/(moduleLoaderState_*, loaderstate,/(loaderstate,/g
41+
s/(moduleLoaderState_*, moduleLoaderState,/(moduleLoaderState,/g
42+
' {} \;
43+

0 commit comments

Comments
 (0)