Re: [go-nuts] Chunked http response with go routines

2019-07-16 Thread Burak Serdar
On Tue, Jul 16, 2019 at 12:03 PM Hasan Genc wrote: > This is my original code. > > Multiple things are wrong with this code: * You are writing to a stream from multiple goroutines with no synchronization. * You are not waiting for the goroutines to complete before returning. Once the http hand

Re: [go-nuts] Chunked http response with go routines

2019-07-16 Thread Jakob Borg
At a guess, because your goroutine is running after the response handler has returned, and at that point the ResponseWriter isn’t valid any more. //jb On 16 Jul 2019, at 20:03, Hasan Genc mailto:hasangenc.istan...@gmail.com>> wrote: This is my original code. outside of the go routine w varia

Re: [go-nuts] Chunked http response with go routines

2019-07-16 Thread Hasan Genc
This is my original code. outside of the go routine w variable is [image: Screen Shot 2019-07-16 at 20.57.35.png] But inside the go routine [image: Screen Shot 2019-07-16 at 20.58.17.png] I don't understand why. Anyone can help about this ? func Make(w http.ResponseWrit

Re: [go-nuts] Chunked http response with go routines

2019-07-15 Thread Hasan Genc
Sorry, I made a mistake when copy paste :) Actually we can assume above code as go func() { ... } Because I want to reference of w variable which is the type of http.ResponseWrite. My actual problem is w.wr is nil inside go routine. I can post the code today but I can not access the code right

Re: [go-nuts] Chunked http response with go routines

2019-07-15 Thread Burak Serdar
On Mon, Jul 15, 2019 at 12:14 PM wrote: > > flusher, ok := w.(http.Flusher) > > > // w.wr is io.Writer here > > > for _, gateway := range app.Gateway { > > > go func(w http.ResponseWriter) { > > // w.wr is nil here > > > tmpl, err := template.New(gateway.Name).Parse(gateway.Content) > >

[go-nuts] Chunked http response with go routines

2019-07-15 Thread hasangenc . istanbul
flusher, ok := w.(http.Flusher) // w.wr is io.Writer here for _, gateway := range app.Gateway { go func(w http.ResponseWriter) { // w.wr is nil here tmpl, err := template.New(gateway.Name).Parse(gateway.Content) if err != nil { panic("An Error occured when parsing