On Tuesday 8 October 2024 at 07:37:25 UTC+1 Axel Wagner wrote: the only one on the "mixing receiver kinds is sometimes necessary, so we shouldn't caution against it" side of the table
To me this sounds like a false dichotomy. It can be good general good-practice advice to avoid mixing pointer and value receivers (for various reasons including those raised by Robert Engels), and at the same time, in cases where it is necessary to do so, then clearly it has to be done (by definition of "necessary") as long as it's done with care ("caution"). The advice quoted is given under "Some useful guidelines" at https://go.dev/wiki/CodeReviewComments#receiver-type - it's not a hard-and-fast rule - and is aimed "especially to new Go programmers". If you know what you need and why, then that's fine. As another example: it's general good practice advice to accept interfaces and return concrete types. But for error values, it's necessary to return an interface value. That is an exception to the general rule, but doesn't invalidate it. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f5be82e4-dd89-40c2-9603-f240748e23dcn%40googlegroups.com.