Hacker News new | ask | show | jobs
by geenat 23 days 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

4 comments

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
That actually looks great. Thanks a lot for the link.
Yes, I'm so happy it has been accepted. It will particularly useful to pass named parameters to functions.
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"}