Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Second, a key in a struct literal may now be any valid field selector for the struct type, allowing fields in nested or embedded structs to be initialized directly

It's been a while since I've written more than anything trivial in golang, but this seems like a big deal to me. As in, I can define a struct that is consistent and reusable in other structs



This will shorten many test files!


This is quite a QoL issue, but is it big? Nothing changes from functional point of view.


It will be very nice working with code generators like oapi-codegen that can generate either nested structs or very unwieldy struct names. So big in that context, but like you said just a nice qol improvement most of the time.


If I'm being honest, I actually hate this feature. I like things being obvious, and structs were always something I could rely on being very explicit.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: