* Fei Ding [160918 02:58]:
> Thanks, Marvin, I've learned a lot from your reply. And, I've written more
> code, like:
>
> a, b, c := 1, 2, 3
> > slice1 := []int{a, b, c}
> > for _, n := range slice1 {
> > go func(n *int) {fmt.Println(*n)}(&n)
> > }
>
>
> It seems that pass *n's address *in the
https://play.golang.org/p/bVizbGIMDp should work
--
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://play.golang.org/p/9LQMDrDIOv should work.
--
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, visi
Thanks, Marvin, I've learned a lot from your reply. And, I've written more
code, like:
a, b, c := 1, 2, 3
> slice1 := []int{a, b, c}
> for _, n := range slice1 {
> go func(n *int) {fmt.Println(*n)}(&n)
> }
It seems that pass *n's address *in the code above will make a data race,
which you have
* Fei Ding [160916 23:30]:
> Link here: https://play.golang.org/p/cdryPmyWt5
>
> The code above is going to check the differences between pointers and
> values in a for loop, while go statement is also used at the same time. For
> code:
>
> values := []field{{"one"},{"two"},{"three"}}
>