I occasionally run into this, but in my experience it's exclusively with maps:
- Initializing empty slices is ~never necessary; (in my opinion the "members: []int{}" from the blog post is a code smell). - Channels need initialization but that's where the important buffered vs. unbuffered choice is made, so I'm happy that's explicit. (I suppose you can say the same about initializing maps with a size, but that's fairly rare in my experience.) - If the struct has a nested pointer to another struct type, then having it be nil is definitely what you want since the nested type may or may not have a valid zero value. On Thu, Feb 22, 2018 at 12:02 PM, Devon H. O'Dell <devon.od...@gmail.com> wrote: > Hi all, > > It's been some time since I really contributed much of anything to the > project (sorry!), but after 8 years, I'm finally writing Go outside of > the project itself (and outside of porting efforts). I was lamenting > to some coworkers about the lack of a comparable feature to C's > "malloc idiom" and they suggested I write an experience report on it. > I wrote the bulk of the article a month ago, but finally put in some > finishing touches and published. > > For whatever it's worth (probably not much): > https://9vx.org/post/a-malloc-idiom-in-go/ > > --dho > > -- > 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.