From 36086e85f842e8ed2c03be2542a6cc211603abbc Mon Sep 17 00:00:00 2001 From: Ian Alexander Date: Thu, 2 Oct 2025 11:15:34 -0400 Subject: [PATCH] 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 TryBot-Bypass: Ian Alexander Commit-Queue: Ian Alexander Reviewed-by: Michael Pratt --- src/cmd/go/internal/rf-cleanup.zsh | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 src/cmd/go/internal/rf-cleanup.zsh diff --git a/src/cmd/go/internal/rf-cleanup.zsh b/src/cmd/go/internal/rf-cleanup.zsh new file mode 100755 index 0000000000..c805db56e3 --- /dev/null +++ b/src/cmd/go/internal/rf-cleanup.zsh @@ -0,0 +1,43 @@ +#!/usr/bin/env zsh + +set -eu -o pipefail + +# 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. + +find . -name '*.go' -exec \ + sed -i ' + # + # CompileAction does not use loaderstate. + # + s/CompileAction(loaderstate[^ ]* \*modload.State, /CompileAction(/g + s/CompileAction(modload.LoaderState[^,]*, /CompileAction(/g + s/CompileAction(loaderstate[^,]*, /CompileAction(/g + # + # cgoAction does not use loaderstate. + # + s/cgoAction(loaderstate \*modload\.State, /cgoAction(/g + s/cgoAction(loaderstate, /cgoAction(/g + s/cgoAction(loaderstate_, /cgoAction(/g + # + # Remove redundant mentions of LoaderState from function call sites. + # + s/(modload\.LoaderState_*, loaderstate,/(loaderstate,/g + s/(modload\.LoaderState_*, moduleLoaderState,/(moduleLoaderState,/g + s/(modload\.LoaderState_*, modload\.LoaderState/(modload.LoaderState/g + s/(modload\.LoaderState_*, loaderstate,/(loaderstate,/g + s/(modload\.LoaderState_*, moduleLoaderState,/(moduleLoaderState,/g + s/(modload\.LoaderState_*, modload\.LoaderState,/(modload.LoaderState,/g + s/(loaderstate_* \*modload.State, loaderstate \*modload.State/(loaderstate *modload.State/g + s/(loaderstate_* \*State, loaderstate \*State/(loaderstate *State/g + s/(loaderstate_*, loaderstate,/(loaderstate,/g + s/(LoaderState_*, loaderstate,/(loaderstate,/g + s/(LoaderState_*, loaderState,/(loaderState,/g + s/(LoaderState_*, LoaderState,/(LoaderState,/g + s/(LoaderState_*, LoaderState,/(LoaderState,/g + s/(moduleLoaderState_*, loaderstate,/(loaderstate,/g + s/(moduleLoaderState_*, moduleLoaderState,/(moduleLoaderState,/g + ' {} \; + -- 2.52.0