For example: By necessity, bufio.Writer can't satisfy io.Writer, because the Write method needs to modify internal state (namely, the buffer), so you need to put a *bufio.Writer into that interface for it to make sense. Now, if you do a bufio.NewWriter(w), with w being a *bufio.Writer, then it would be pretty inefficient, if that would wrap w with *another* buffer. So it will do a type-assertion to *bufio.Writer (remember, it's a pointer that's in the interface, not a value) and just return that, if it succeeds: https://golang.org/src/bufio/bufio.go#L521
In general, you will often find, that only a *T satisfies an interface and whenever that is the case, you must also type-assert it as a *T, of course, because that's the dynamic type of the interface, after all. On Tue, Jun 28, 2016 at 11:13 AM, Michael Wain <michaelwain1...@gmail.com> wrote: > Why would I use *T over just T ? > > Michael > > On 28 Jun 2016, at 10:05, Jan Mercl <0xj...@gmail.com> wrote: > > On Tue, Jun 28, 2016 at 11:02 AM Michael Wain <michaelwain1...@gmail.com> > wrote: > > > So a := x.(*T) is the same as a := x.(T) ? > > No, because T and *T are distinct types. > > > > -- > > -j > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.