Having defined
type MyInt int
I would like to define a method .ShowMe()
that just prints the value. I can define this either using *MyInt
:
func (this *MyInt) ShowMe() {
fmt.Print(*this, "
")
}
Or using MyInt
:
func (this MyInt) ShowMe() {
fmt.Print(this, "
")
}
In what cases is it recommended to define methods on values, instead of on pointers?