6 ms·
Go 1.18 also includes the new net/netip package which is huge, now the Addr type holds less memory, it is comparable and immutable. There is also a great post(
by yagizdegirmenci 5y ago
Go 1.18 also includes the new net/netip package which is huge, now the Addr type holds less memory, it is comparable and immutable.
There is also a great post(See: https://tailscale.com/blog/netaddr-new-ip-type-for-go/ https://tailscale.com/blog/netaddr-new-ip-type-for-go/) in Tailscale's blog which deep dives into why we needed a new IP type/library in Go.
- onphonenow 5y agoI'm far more excited by Addr / netip then generics :)
- lifty 5y agoIs this Tailscale’s library imported into Go’s stdlib?
- pphysch 5y agoYep
- benhoyt 5y agoYes, after some discussion and minor modifications (and removal of a few features): https://github.com/golang/go/discussions/47323 https://github.com/golang/go/discussions/47323 ... I understand the motivation for this new package, but it does seem like a large API surface to have imported into the stdlib.
- na85 5y agoIsn't that one of Go's main value propositions? A batteries-and-kitchen-sink-included stdlib?
- philosopher1234 5y agoKitchen sink seems too far. Batteries is part of it.
- pstuart 5y agoBeing that this is coming from a (former) core maintainer of the stdlib I think it's worthy.
- kortilla 5y agoWho it came from is irrelevant
- voidfunc 5y agoNo it's not. Someone who is a former core maintainer likely has better perspective on what belongs or doesn't than 99% of the community. There's a reason most stdlib and language decisions in Go are run through an extremely small cabal of people.
- owaislone 5y agoI think what OP is trying to say is that the merit of a given feature alone should determine whether it goes into the stdlib or not and author's reputation should not result in something being merged that wouldn't otherwise.
- scns 5y agoWell, your sentence contains the word should two times. To me, this indicates a wish that differs from reality.
- pstuart 5y agoOf course it should have merit, and it does. I invoked the author's reputation in that he previously had both contributed and determined merit -- his opinion carries far more weight than any random gopher.
- ccakes 5y agoHadn't seen this but yeah, a much needed improvement!
- naikrovek 5y agowhere does one find a comprehensive list of new things for each version? the release notes never seem to know everything that people in here know.
- sabellito 5y agoI haven't done any Go in my life, but this bit about immutability interests me. Is there a general movement in the Go community towards immutable data structures?
- lbhdc 5y agoI don't think there is a movement towards immutable data structures. The const keyword only works on basic types (bool, num, str). Objects can have private member variables, but those are only private on the module level. You can also pass by copy instead of passing a pointer.
- BreakfastB0b 5y agoThis is something I'm hoping will change with the introduction of Generics. Right now using any custom data structures like immutable map or lists are very cumbersome requiring either code generation or runtime type coercion via `interface{}`. Go espouses "Share by communicating, don't communicate by sharing" i.e. don't let goroutines communicate by mutating shared data, but then doesn't provide any effective immutable data structures to make this easy. Being able to safely send pointers to immutable maps over channels would make go very nice to work with. Although I'll never use Go outside of work until they remove nullable pointers which seems unlikely.
- smokey_circles 5y agoChannels. Share information between routines with channels. If you're passing pointers to mutate down a channel, then that's on you. Just set yourself on fire, much easier that way lol. You don't need immutable structures to communicate between goroutines. Value types are fine. Just think a bit about how to use channels as signal carriers, it eventually starts to make sense
- BreakfastB0b 5y agoI think I miscommunicated what I meant, there was an implicit assumption that copying value types over channels was bad due to GC overhead. Efficient Immutable data structures let you have your cake and eat it too. You can avoid GC overhead by sharing structure but avoid problems with mutation between goroutines.
- jaytaylor 5y agoAlso see past HN thread about it: https://news.ycombinator.com/item?id=26416553 https://news.ycombinator.com/item?id=26416553