Thanks a lot Uli,  &Peter,

@Uli
The go routine safe rand.Int63 resolved the problem.


Regards
Mukund


On Wed, Apr 5, 2017 at 12:51 AM, Uli Kunitz <uli.kun...@gmail.com> wrote:

> Hi Mukund,
>
> Please recognize that the Source object returned by rand.NewSource is not
> safe for concurrent use by multiple goroutines. Look at the documentation
> of NewSource in package math/rand. You are defining r as a global variable
> and probably call pickENI() from multiple goroutines, which is running into
> an issue. The example program will not generate a problem, because it
> doesn't call pickENI() in multiple goroutines.
>
> The easy way out is to use rand.Int63 instead of r.Int63. It uses a source
> that is protected against use in multiple goroutines. You might want to use
> Seed to prevent the generation of the same ENI in each run. Alternatively
> you could write a lock-protected source yourself, it shouldn't be too
> difficult.
>
> Uli
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to