Re: [go-nuts] Run a goroutine until a channel receives a message

2021-01-14 Thread Toon Knapen
Note from the gorilla websocket documentation ' *SetReadDeadline sets the read deadline on the underlying network connection. After a read has timed out, the websocket connection state is corrupt and all future reads will return an error. A zero value for t means reads will not time out.*' Th

Re: [go-nuts] Run a goroutine until a channel receives a message

2021-01-13 Thread Sankar P
> > if `ws.Read` returns after a reasonable timeout, you can perform a > non-blocking receive on the quit channel to see if it has been > closed/something has been sent to it: > > select { > case <-quit: > break > default: >

Re: [go-nuts] Run a goroutine until a channel receives a message

2021-01-13 Thread Gregor Best
Hi, if `ws.Read` returns after a reasonable timeout, you can perform a non-blocking receive on the quit channel to see if it has been closed/something has been sent to it: select { case <-quit: break default:

[go-nuts] Run a goroutine until a channel receives a message

2021-01-13 Thread Sankar
I have a function that must be executed as a go routine infinitely until a message comes in a channel. For example: func readWebSocket(ws *websocket.socket, quit chan bool) { for { out, err = ws.Read() log.Println(out, err) } } Now I call this above function as a goroutine from ma