Unless you pass pointers in Go, every time you hop in and out of a new 
scope any changes are discarded. This is why unless you type-bind with 
pointers you don't actually have an OOP method, as the function will not 
act upon the parent variable/structure.

I think if you change your playground code to pass pointers into the 
goroutines you'll either see race detector or clobbering.

On Saturday, 21 April 2018 16:30:22 UTC+3, Ankit Gupta wrote:
>
> @Kaveh
>
> Slices are values but they refer to the same back array location. You have 
> created localized v which is appended inside goroutine which refer to a 
> location containing its own byte array of len=10. So, you are not really 
> referencing the same memory location as other v slice in the goroutine. You 
> will be affected if you remove k,v:=k,v or append more than 10 bytes to v 
> inside goroutine which will take up space on next slice's bytes. 
>
> On Saturday, April 21, 2018 at 2:30:53 PM UTC+5:30, Kaveh Shahbazian wrote:
>>
>> @ Louki Sumirniy
>> Slices are values AFAIK. There is no passby pointer.
>>
>> And the point is, race detector does not flag anything: 
>> https://play.golang.org/p/NC8mBwS1-0P
>>
>

-- 
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