Re: [go-nuts] Methods and pointer type receivers

2021-02-28 Thread Howard Waterfall
Thanks Brian. It sounds like golang made it illegal to define methods on a defined pointer type for readability/disambiguation reasons rather than some fundamental, underlying technical issue. Frankly the confusion it eliminates still isn’t entirely clear to me. Given that names in general don’t

Re: [go-nuts] Methods and pointer type receivers

2021-02-27 Thread Ian Lance Taylor
On Sat, Feb 27, 2021 at 7:03 PM Deiter wrote: > > Go: go1.15.8 darwin/amd64 > OS: MacOS 11.2.1 > > The program here includes a type and a method that acts on that type: > > type Prefix struct { > prefix string > } > > func (rec *Prefix) outputString(s string) { > fmt.Printf("%v: %v\n",

Re: [go-nuts] Methods and pointer type receivers

2021-02-27 Thread Kurtis Rader
On Sat, Feb 27, 2021 at 7:03 PM Deiter wrote: > >1. Why can’t receivers be a pointer type? > > They can be a pointer type. See, for example, https://tour.golang.org/methods/8. Also, as I write this the https://play.golang.org/p/rmnIexAGU-O you provided works. -- Kurtis Rader Caretaker of

[go-nuts] Methods and pointer type receivers

2021-02-27 Thread Deiter
Go: go1.15.8 darwin/amd64 OS: MacOS 11.2.1 The program here includes a type and a method that acts on that type: type Prefix struct { prefix string } func (rec *Prefix) outputString(s string) { fmt.Printf("%v: %v\n", rec.prefix, s) } Very