[go-nuts] Re: ListenAndServ and channels

2018-01-06 Thread Amnon Baron Cohen
The global var should have been protected by a mutex, or loaded and saved using sync/atomic functions, as it is accessed from multiple goroutines. Another minor point: Why do: result := fmt.Sprintf("Hello there %s", i) io.WriteString(w, result) instead of just: fmt.Fprintf(w, "Hello there %s",

[go-nuts] Re: ListenAndServ and channels

2018-01-05 Thread Amnon Baron Cohen
try using a global var. something like https://play.golang.org/p/05-xBDh5rgn On Thursday, 4 January 2018 15:09:41 UTC, Keith Brown wrote: > > I am trying to Serve a webpage while running a ticker in the background. I > am trying to generate a random number, genRandom() , periodically and >