[go-nuts] x/net/Listen behaviours

2019-09-05 Thread jgrime
Hi! I'm having some confusion over the behaviour of net.Listen() and it's interactions with http.Server. Can anyone take a look at this, and let me know what I'm doing wrong? Thanks! System description - Go: go version go1.12.9 darwin/amd64 OS: macOS Mojave (10.14.6)

[go-nuts] Re: x/net/Listen behaviours

2019-09-06 Thread jgrime
Hi Jacques, Thanks for the help! > when you call listener, err := net.Listen("tcp4", addrString) it does indeed only listen to "tcp4". Later, when you call server.ListenAndServe() (because listener is nil), the system seems to "re-listen" from the same port and then it listen to "tcp" and not

[go-nuts] Re: x/net/Listen behaviours

2019-09-06 Thread jgrime
Ahh, I think I understand the problem! I assumed that "listener, err := ..." would use the existing listener variable (creating err on the spot), rather than creating a new locally-scoped listener? Therefore, as you said, listener is basically always nil outside that "if useListener>0 {}" scop

[go-nuts] Re: x/net/Listen behaviours

2019-09-06 Thread jgrime
You're absolutely right, Jacques! I completely misunderstood this from the Go documentation : Redeclaration does not introduce a new variable; it just assigns a new value to the original. .. because I did not understand the difference be