]>
Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/modload: make State.modfetchState a pointer
This change aligns modfetch.State with modload.State by using pointer
parameters and receivers.
[git-generate]
cd src/cmd/go/internal/modload
sed -i '
s/oldState/old/
s/old := State{/old = \&State{/
s/func (s \*State) setState(new State) State {/func (s *State) setState(new *State) (old *State) {/
s/setState(State{})/setState(NewState())/
' init.go
cd ../modfetch
sed -i '
s/oldState = State{/oldState = \&State{/
s/func SetState(newState State) (oldState State) {/func SetState(newState *State) (oldState *State) {/
s/SetState(State{})/SetState(NewState())/
' fetch.go
cd ../modload
sed -i '
s/old.modfetchState = modfetch.SetState(new.modfetchState)/_ = modfetch.SetState(\&new.modfetchState)/
' init.go
rf '
#
# Prepare to swap the existing modfetchState field for a pointer type
#
mv State.modfetchState State.modfetchState_
add State:/modfetchState_/+0 modfetchState *modfetch.State
#
# Update State.setState to set & restore additional values
#
add State.setState:/s\.requirements,/+0 workFilePath: s.workFilePath,
add State.setState:/s\.workFilePath,/+0 modfetchState: s.modfetchState,
#
# Swap the existing modfetchState field for a pointer type
#
add init.go:/.* = modfetch.SetState\(.*\)/-0 s.modfetchState = new.modfetchState
add init.go:/.* = modfetch.SetState\(.*\)/-0 old.modfetchState = modfetch.SetState(s.modfetchState) // TODO(jitsu): remove after completing global state elimination
rm init.go:/_ = modfetch.SetState\(.*\)/
rm State.modfetchState_
'
sed -i '
s/return &State{}/s := new(State)\ns.modfetchState = modfetch.NewState()\nreturn s/
' init.go
go fmt
Change-Id: I0602ecf976fd3ee93844e77989291d729ad71595
Reviewed-on: https://go-review.googlesource.com/c/go/+/720900
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>