Hacker News new | ask | show | jobs
by zeeboo 3399 days ago
You can leave the inner type out...

https://play.golang.org/p/m3bLmneArB

1 comments

Ah, maybe it's when they're alias types that that wouldn't work?
Actually I just tried that and it worked also. But I think you're right that this hasn't always been the case because I remember being annoyed about it. Or maybe we're both crazy.

You definitely need to specify the type for an interface, but that makes sense.

You're not crazy. I also have vague memories of maps being more obnoxious in Go. :)

The facts are that map literals did change a bit in Go 1.5 (i.e. fairly recently), full literal specification for values could already be elided back then - it was KEYS that required full specification: https://golang.org/doc/go1.5#map_literals

If you go way more back, Go 1 also saved some typing on values, in case they were pointers: https://golang.org/doc/go1#literals