It's not and it's easy to test:

Save as t.go:

package main
import "fmt"

func main() {
 var s []int
 for i := 0; i < 100000; i++ {
 go func(n int) {
 s = append(s, n)
 }(i)
 }
 fmt.Printf("%d\n", s[0])
}


hen `go run -race t.go` and watch race detector complain.

-- kjk


On Thursday, January 19, 2017 at 1:43:13 PM UTC-8, xiaohai dai wrote:
>
> I know that map in golang is not thread-safe for writing.
> However, I'm not sure slice/array is thread-safe for writing. I have 
> searched the related posts and blogs in google, but find no unambiguous 
> statement.
>
> Thanks in advance! 
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to