News for hackers. Stuff that matters.
Re:Three Minor Features in Go 1.18 by yagizdegirmenci on Wednesday December 22, 2021 @02:21PM (#29653815)
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/) in Tailscale's blog which deep dives into why we needed a new IP type/library in Go.

Re:Three Minor Features in Go 1.18 by onphonenow on Wednesday December 22, 2021 @02:39PM (#29654028)
I'm far more excited by Addr / netip then generics :)
Re:Three Minor Features in Go 1.18 by sabellito on Wednesday December 22, 2021 @04:34PM (#29655636)
I 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?
Re:Three Minor Features in Go 1.18 by lbhdc on Wednesday December 22, 2021 @04:58PM (#29655973)
I 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.
Re:Three Minor Features in Go 1.18 by BreakfastB0b on Thursday December 23, 2021 @12:33AM (#29658981)
This 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.

Re:Three Minor Features in Go 1.18 by smokey_circles on Thursday December 23, 2021 @01:10AM (#29659154)
Channels. 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

Re:Three Minor Features in Go 1.18 by BreakfastB0b on Thursday December 23, 2021 @02:45AM (#29659595)
I 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.
Re:Three Minor Features in Go 1.18 by jaytaylor on Wednesday December 22, 2021 @05:25PM (#29656274)
Also see past HN thread about it:

https://news.ycombinator.com/item?id=26416553

Re:Three Minor Features in Go 1.18 by lifty on Wednesday December 22, 2021 @03:27PM (#29654680)
Is this Tailscale’s library imported into Go’s stdlib?
Re:Three Minor Features in Go 1.18 by benhoyt on Wednesday December 22, 2021 @04:05PM (#29655178)
Yes, after some discussion and minor modifications (and removal of a few features): 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.
Re:Three Minor Features in Go 1.18 by pstuart on Wednesday December 22, 2021 @05:14PM (#29656160)
Being that this is coming from a (former) core maintainer of the stdlib I think it's worthy.
Re:Three Minor Features in Go 1.18 by kortilla on Wednesday December 22, 2021 @09:19PM (#29657925)
Who it came from is irrelevant
Re:Three Minor Features in Go 1.18 by voidfunc on Wednesday December 22, 2021 @10:46PM (#29658438)
No 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.
Re:Three Minor Features in Go 1.18 by owaislone on Thursday December 23, 2021 @03:46AM (#29659943)
I 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.
Re:Three Minor Features in Go 1.18 by pstuart on Thursday December 23, 2021 @06:33PM (#29667847)
Of 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.
Re:Three Minor Features in Go 1.18 by scns on Thursday December 23, 2021 @03:53AM (#29659978)
Well, your sentence contains the word should two times. To me, this indicates a wish that differs from reality.
Re:Three Minor Features in Go 1.18 by na85 on Wednesday December 22, 2021 @05:01PM (#29656004)
Isn't that one of Go's main value propositions? A batteries-and-kitchen-sink-included stdlib?
Re:Three Minor Features in Go 1.18 by philosopher1234 on Wednesday December 22, 2021 @07:07PM (#29657115)
Kitchen sink seems too far. Batteries is part of it.
Re:Three Minor Features in Go 1.18 by pphysch on Wednesday December 22, 2021 @03:38PM (#29654820)
Yep
Re:Three Minor Features in Go 1.18 by ccakes on Wednesday December 22, 2021 @04:09PM (#29655233)
Hadn't seen this but yeah, a much needed improvement!
Re:Three Minor Features in Go 1.18 by naikrovek on Wednesday December 22, 2021 @04:24PM (#29655463)
where 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.
Re:Three Minor Features in Go 1.18 by lbhdc on Wednesday December 22, 2021 @05:11PM (#29656123)
I normally look at the go blog. Their post about 1.18 linked the detailed release notes.

https://tip.golang.org/doc/go1.18

Re:Three Minor Features in Go 1.18 by scns on Thursday December 23, 2021 @04:01AM (#29660027)
I like the addition of the GOAMD64 environment variable. It allows you to use the capabilities of your CPU.

V2 - Nehalem/Jaguar

V3 - Haswell/Excavator

V4 - AVX512

Re:Three Minor Features in Go 1.18 by naikrovek on Thursday December 23, 2021 @11:32AM (#29663450)
Agree, this is a good addition.
Re:Three Minor Features in Go 1.18 by crtc on Wednesday December 22, 2021 @09:38PM (#29658035)
The release notes usually contain everything.