On Sat, 2017-02-25 at 09:03 +, Jan Mercl wrote:
> They're not, #2 has a data race.
There is no race, the go routine is not a closure.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails f
On Sat, Feb 25, 2017 at 9:58 PM, Ayan George wrote:
>
>
> On 02/25/2017 03:48 AM, Amit Saha wrote:
>>
>> I think both these approaches are fine, but just wanted to check.
>>
>
> tl;dr: I think the second example is the way to go.
>
> I'm somewhat new to Golang so please someone correct me if I'm w
On 02/25/2017 03:48 AM, Amit Saha wrote:
>
> I think both these approaches are fine, but just wanted to check.
>
tl;dr: I think the second example is the way to go.
I'm somewhat new to Golang so please someone correct me if I'm wrong.
Neither of your examples are closures and, AFAIK, they're
On Sat, Feb 25, 2017 at 8:03 PM, Jan Mercl <0xj...@gmail.com> wrote:
>> I think both these approaches are fine, but just wanted to check.
>
> They're not, #2 has a data race.
Thanks, can you please explain how or point me to a doc/post explaining it?
>
> --
>
> -j
--
http://echorand.me
--
> I think both these approaches are fine, but just wanted to check.
They're not, #2 has a data race.
--
-j
--
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 gol
Hello,
When spawning goroutines in a for loop - is there any reason to prefer
approach #1 below versus #2 or vice-versa?
Approach #1: Using a closure
func printme(val int) {
// Do something with val
}
func main() {
slice := []int{1, 23, 100, 101}
for _, val := range slice {
go func(v