Starting with code like:
type Foo struct {
V bool
}
func (f Foo) bar() bool {
return f.V
}
Is it allowed to change to func (f *Foo) bar() bool without incrementing the major version number? That is, assuming you know there are no thread safety issues with your type. If so, the reverse change is allowed too, correct?
Any code that called the function regardless of whether the variable was a value or a pointer would continue to compile and work as expected after both changes, as far as I can tell.
As per the comments, this answer answer provides a good summary
Tvs*Treceiver types. Following are a couple of examples where a change fromfunc (f Foo) bar() booltofunc (f *Foo) bar() boolwould break existing code.Example 1:
Tis not addressable (playground):Example 2: Interface (playground):