News for hackers. Stuff that matters.
Re:Gopher Tricks by XorNot on Friday August 21, 2015 @02:58PM (#10099541)
In practice I've not found anonymous structs too useful. You end up being very verbose and then discover you'd have been better off with a named type anyway.

It'd be nice to have a shorthand which mixed the type definition and assignment into a single line so you could do something like:

S := { x int : 1, y int : 2 }

Or even

S:= { x := 1, y := 2 }

Re:Gopher Tricks by PuerkitoBio on Friday August 21, 2015 @03:23PM (#10099684)
I use them extensively for test cases (`cases := []struct{...} { ... }`) as mentioned in the slides. Also sometimes to marshal/unmarshal one-off json or xml payloads.