logoalt Hacker News

geenatyesterday at 9:10 PM4 repliesview on HN

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


Replies

ngrillytoday at 5:43 PM

Yes, I'm so happy it has been accepted. It will particularly useful to pass named parameters to functions.

nasretdinovtoday at 8:43 AM

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

joaohaastoday at 12:13 PM

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"}
p2detaryesterday at 9:53 PM

That actually looks great. Thanks a lot for the link.