← Back to context

Comment by geenat

20 hours ago

If verbosity is a main stickler, this is coming to golang 1.28 which will cut it down drastically:

https://github.com/golang/go/issues/12854#issue-110104883

Being able to just return {}, err when returning an empty struct from a function sounds really exciting and encouraging to use pointers less, which is really good for nil safety if anything

I know general consensus on this is that it is good, but I hate this. The fact that both assignments do completely different things (with the map one doing heap allocs!) is insane. This would've been much better if it only allowed for anonymous structs.

  var A string = "A"
  type Foo struct { A string }
  var a Foo
  var b map[string]string
  
  a = {A: "abc"}
  b = {A: "abc"}