Is there are way to rename the receiver variable name in all methods of a type (using the AST/gopls
, i.e. not by using find and replace)?
E.g.:
type PointLight struct {
}
func (pl *PointLight) DoThis() {
pl.foo()
}
func (pl *PointLight) DoThat() {
pl.bar()
}
// ...
Let’s say I decide to rename this type to be called SphereLight
instead. I can easily do that by pressing F2 on the type declaration.
type SphereLight struct {
}
func (pl *SphereLight) DoThis() {
pl.foo()
}
func (pl *SphereLight) DoThat() {
pl.bar()
}
// ...
However, the receiver variable name still reads pl
(short for PointLight
). After the rename, I would like for them to be called sl
(short for SphereLight
) instead.
type SphereLight struct {
}
func (sl *SphereLight) DoThis() {
sl.foo()
}
func (sl *SphereLight) DoThat() {
sl.bar()
}
// ...
The only way I know how to do this is to press F2 on every single receiver. Is there a way to do it with a single action?