Re: [go-nuts] Imitating tuple in golang

2024-08-10 Thread p...@morth.org
I think when discussing tuples one should consider the [...]any type as an alternative to []any. Arrays supports comparison, aren't boxed and are generally more tuple-like. They can be used as map keys. Of course, they're still not really type-safe. Structs solve that and also support access by

[go-nuts] Re: HTTP method before the endpoint

2024-06-03 Thread p...@morth.org
Hi, It works on the playground at least, https://go.dev/play/p/YZbgmezjSIV Are you sure your server is listening on port 80? That's fairly uncommon for service code and usually requires extra permissions. If it's listening on another port, you'll have to specify that in the browser as well (see

[go-nuts] Re: net.Listen -- How to listen to ipv6 & ipv4 local-loopback BUT NOT external interfaces

2024-01-11 Thread p...@morth.org
Hi, Unfortunately, the only way to avoid having two sockets in this scenario, is to listen to only one of 127.0.0.1 or ::1 and live with that it's only one address family. As you might've noticed, some tools still struggle with connecting to ::1 so listening to 127.0.0.1 is the most safe option

Re: [go-nuts] Missing the review meeting notes

2023-10-02 Thread p...@morth.org
e 2023-09-20 meeting, > which I've just done. > There was no 2023-09-27 meeting due to GopherCon. > > Best, > Russ > > > On Mon, Oct 2, 2023 at 7:14 AM p...@morth.org wrote: > >> Hi, >> >> I might just be out of the loop, but it seems the review

[go-nuts] Missing the review meeting notes

2023-10-02 Thread p...@morth.org
Hi, I might just be out of the loop, but it seems the review meeting notes are no longer posted since a few weeks back, https://github.com/golang/go/issues/33502 I really enjoyed reading these, it was a highlight of the week. Can I expect these to be continued or has the process changed someho

[go-nuts] Re: Interesting "select" examples

2023-04-07 Thread p...@morth.org
Sarama's producer might qualify as interesting. https://pkg.go.dev/github.com/Shopify/sarama#example-AsyncProducer-Select You're supposed to produce messages on a channel while simultaneously listening for acks (optional) and errors (mandatory) in the same select loop. Regards, Per Johansson O

Re: [go-nuts] Silly question about parentheses

2023-02-01 Thread p...@morth.org
It would actually be ambiguous in the very place they're required. Consider this not completely unreasonable example: https://go.dev/play/p/OL0uOnPZXju Also, with generics it could be ambiguous in type parameters. To summarize, parentheses are needed around the return types because otherwise an

[go-nuts] Re: Unmarshal variable JSON structures

2022-12-29 Thread p...@morth.org
Hi! It's not possible to decode this data without scanning it twice. It's a flawed design where someone has chosen to make that restriction. programming language doesn't matter. The only way to avoid parsing it twice is to decode to a map[string]any and then use that as-is. Which I suppose you

[go-nuts] Re: How to check Cmd.ProcessState without triggering the race checker?

2022-07-25 Thread p...@morth.org
Hi, I think you need to restructure your code, because what you're actually doing is checking whether the pid is valid or not. Since the pid is made invalid inside the Wait call (in the kernel), before ProcessState is set, there's no way to do that safely. Instead, you should avoid calling Wait