If I run it locally it's not consistent:
go run lock/main.go
[3 0 1 2 5 4 6 9 7 8] 10⏎
go run lock/main.go
[1 5 6 7 8 0] 6⏎
go run lock/main.go
[0 3 1 2 4 5 6 7 8] 9⏎
Here's a version that does work for me: https://play.golang.org/p/b6bRb9pgIGZThe issue is that appending to slices concurrently is not safe, so you have to use a lock around the append or similar.