Get the latest tech news

Go structs are copied on assignment (and other things about Go I'd missed)


Go structs are copied on assignment (and other things about Go I'd missed)

The bug I spent 2 hours of my life debugging last week was effectively this code ( play.go.dev link): This prints out[{record} {banana}] – because findThing returned a copy, we didn’t change the name in the original array. apparently you can , though that can have and I’m not sure I want to to ensure that you only use the package’s public interfaces, which seems really useful there are a lots of notes about how to use contexts, channels, goroutines, mutexes, sync.WaitGroup, etc.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of things

things

Photo of assignment

assignment

Photo of structs

structs

Related news:

News photo

Things I've learned building a modern TUI Framework (2022)

News photo

Things I Won't Work With: Dimethylcadmium (2013)

News photo

A US Judge Ruled That Google Is an Illegal Monopolist. Here's What Might Come Next