I have the following method defined:
func (o *MyObj) parse(something string) string {
// Do stuff
}
This code (1) compiles just fine:
(&MyObj{}).parse(myString)
This code (2) compiles too:
m := MyObj{}
m.parse(myString)
But this code (3) doesn't compile:
MyObj{}.parse(myString)
With the error
Cannot call a pointer method on 'MyObj{}'
My questions:
Why (2) compiles? I read that T method set doesn't include *T method set, hence I'd expect it not to compile.
Given (2) compiles, why wouldn't (3) compile??