[go-nuts] Trying to understand HTTP connection pooling behaviour - new DNS lookup

2020-11-27 Thread Amit Saha
Hi, it seems that the http client automatically performs a DNS lookup when an existing connection is terminated by the server. I simulated it via changing the IP address in /etc/hosts. Can someone point me to the code where this logic is checked? I am looking at

[go-nuts] Give the zero time value a location, and it won't survive a roundtrip to JSON?

2020-11-27 Thread 'Robert Ma' via golang-nuts
Hi all, Time is complicated. Today I found myself in a rabbit hole. For some unrelated reason, I got a time value in a non-UTC location that's otherwise zero (IsZero=true). This value doesn't seem to survive a roundtrip to JSON. See this playground for a minimal reproduction:

[go-nuts] Re: Give the zero time value a location, and it won't survive a roundtrip to JSON?

2020-11-27 Thread 'Robert Ma' via golang-nuts
Is this because the 2-second offset of LMT gets lost in RFC 3339 representation? On Fri, Nov 27, 2020 at 6:33 PM Robert Ma wrote: > Hi all, > > Time is complicated. > > Today I found myself in a rabbit hole. For some unrelated reason, I got a > time value in a non-UTC location that's otherwise

Re: [go-nuts] History & origins of the Go memory model

2020-11-27 Thread Ian Lance Taylor
On Fri, Nov 27, 2020 at 12:57 PM Daniel Fava wrote: > > Does anyone know how the Go memory model came to be? I don't have technical > questions about it. I just would like to know the historical context. > > The model is specified in terms of happens-before, due to Lamport. But the >

[go-nuts] History & origins of the Go memory model

2020-11-27 Thread Daniel Fava
Hi, Does anyone know how the Go memory model came to be? I don't have technical questions about it. I just would like to know the historical context. The model is specified in terms of happens-before, due to Lamport. But the following rule, which allows channels to be used as locks, was

Re: [go-nuts] concurrency safety

2020-11-27 Thread Øyvind Teig
Great! I liked Mill's lecture. After having seen it, here's my favourite: *Clojure core.async*, lecture (45 mins). Rich Hickey discusses the motivation, design and use of the Clojure core.async library. He also talks about go. See https://www.infoq.com/presentations/clojure-core-async/

Re: [go-nuts] [generics] Separating type parameters, regular parameters, and return parameters

2020-11-27 Thread Robert Engels
This is best solved by syntax highlighting in an editor. Doesn’t do much for b & w printed training materials - but you can achieve similar results with bold / font choice. > On Nov 27, 2020, at 9:49 AM, 'Axel Wagner' via golang-nuts > wrote: > >  >> On Fri, Nov 27, 2020 at 3:42 PM Yaw

Re: [go-nuts] [generics] Separating type parameters, regular parameters, and return parameters

2020-11-27 Thread 'Axel Wagner' via golang-nuts
On Fri, Nov 27, 2020 at 3:42 PM Yaw Boakye wrote: > I disagree on accepting "that generic function signatures are inherently > more crowded and less readable." I mean, inherently more crowded and less > readable looks like something that one should apologize for (1) when > teaching the language,

Re: [go-nuts] [generics] Separating type parameters, regular parameters, and return parameters

2020-11-27 Thread Yaw Boakye
On potentially introducing backwards incompatible change, good point. I agree that we shouldn't which means the colon would be optional. I disagree on accepting "that generic function signatures are inherently more crowded and less readable." I mean, inherently more crowded and less readable

Re: [go-nuts] [generics] Separating type parameters, regular parameters, and return parameters

2020-11-27 Thread 'Axel Wagner' via golang-nuts
On Fri, Nov 27, 2020 at 3:14 PM wher...@gmail.com wrote: > I'd like to propose that we separate the type and function parameters from > the return parameters with a colon > That would mean that either a) generic and non-generic functions would differ by a : after the arguments, which seems

Re: [go-nuts] errors.Is and pointer arguments

2020-11-27 Thread Arve Knudsen
Thanks, Jan, but the error type in question is 3rd party so can't be extended with Is() :) Best, Arve On Fri, Nov 27, 2020 at 3:00 PM Jan Mercl <0xj...@gmail.com> wrote: > On Fri, Nov 27, 2020 at 2:46 PM Arve Knudsen > wrote: > > > I've noticed that errors.Is returns false if you compare two

[go-nuts] [generics] Separating type parameters, regular parameters, and return parameters

2020-11-27 Thread wher...@gmail.com
Hello, Consider the code below (taken from the Design Draft and slightly modified): func ConcatTo[S Stringer, P Plusser](s []S, p []P) (r []string) { r = make([]string, len(s)) for i, v := range s { r[i] = p[i].Plus(v.String()) } return r } It becomes immediately obvious that the

Re: [go-nuts] errors.Is and pointer arguments

2020-11-27 Thread Jan Mercl
On Fri, Nov 27, 2020 at 2:46 PM Arve Knudsen wrote: > I've noticed that errors.Is returns false if you compare two error instances > that are implemented as pointers. I.e., I'm using a struct where the Error > method has a pointer receiver, and when passing struct instance pointers to >

[go-nuts] Re: errors.Is and pointer arguments

2020-11-27 Thread Arve Knudsen
Actually, never mind about this. I realized in the meantime that I shouldn't be using `errors.Is` in this case, where I basically want to see if the error is of a certain type. `errors.As` makes more sense for this use case. On Friday, November 27, 2020 at 2:46:36 PM UTC+1 Arve Knudsen wrote:

[go-nuts] errors.Is and pointer arguments

2020-11-27 Thread Arve Knudsen
Hello! I've noticed that errors.Is returns false if you compare two error instances that are implemented as pointers. I.e., I'm using a struct where the Error method has a pointer receiver, and when passing struct instance pointers to errors.Is, it ends up comparing them by pointer address.

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-27 Thread b.ca...@pobox.com
I should add: using channels often means the mutex is not required. Imagine, for example, that you want a concurrency-safe counter (that multiple goroutines can read, increment and decrement). You can put the counter value into a buffered channel: counter := make(chan int, 1) counter <- 0

Re: [go-nuts] concurrency safety

2020-11-27 Thread b.ca...@pobox.com
On Friday, 27 November 2020 at 10:32:11 UTC oyvin...@teigfam.net wrote: > Thread safety, concurrency safety, goroutines safety. The same stuff to > me. > > It's important that concurrent goroutines don't interfere with each other > in such a way that internal state is compromised by other

Re: [go-nuts] Re: mount remote storage without FUSE

2020-11-27 Thread 'Axel Wagner' via golang-nuts
Yeah, NFS would work as well (similar tradeoffs as 9P, though the linux kernel driver might perform better because it's more widely used). nbd is not suitable for the use case, I think :) I'd also recommend against using my nbd package if performance is the goal - it is not at all optimized, I

Re: [go-nuts] concurrency safety

2020-11-27 Thread Øyvind Teig
Thread safety, concurrency safety, goroutines safety. The same stuff to me. It's important that concurrent goroutines don't interfere with each other in such a way that internal state is compromised by other goroutines. Typically through access to internal data, through pointers. If only go

[go-nuts] Re: mount remote storage without FUSE

2020-11-27 Thread Didier Spezia
One possibility is to use the 9P client of the kernel and implements a 9P server in Go - there are a few 9P libraries for Go around. I doubt it will be more efficient than FUSE though, and btw FUSE is largely based on the ideas promoted by 9P. Another possibility is to use the ndb client of the

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-27 Thread Afriyie Abraham Kwabena
Hi, THanks!! BR Abraham On Friday, November 27, 2020 at 11:12:53 AM UTC+2 b.ca...@pobox.com wrote: > On Friday, 27 November 2020 at 06:14:48 UTC Afriyie Abraham Kwabena wrote: > >> What I would like to ask is, using mutex OK and if not the best way of >> solving it, how can i use >> channels

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-27 Thread b.ca...@pobox.com
On Friday, 27 November 2020 at 06:14:48 UTC Afriyie Abraham Kwabena wrote: > What I would like to ask is, using mutex OK and if not the best way of > solving it, how can i use > channels in this case. > There's nothing wrong with mutex, but you can use channels for a more native-Go experience.