News for hackers. Stuff that matters.
Re:Go 1.9 is released by alphaalpha101 on Thursday August 24, 2017 @06:57PM (#15094788)
So this new concurrent map? Am I right in understanding it's designed for cases where you have a map shared between goroutines but where each goroutine essentially owns some subset of the keys in the map?

So basically it's designed for cases like 'I have N goroutines and each one owns 1/N keys'?

Re:Go 1.9 is released by vanderZwan on Thursday August 24, 2017 @07:13PM (#15094882)
> each goroutine essentially owns some subset of the keys in the map

With those constraints, why not create a small map for each goroutine at that point, and merge the maps afterwards?

Re:Go 1.9 is released by imaginenore on Saturday August 26, 2017 @10:05AM (#15105489)
Then you have to merge them on every read (after any modification).
Re:Go 1.9 is released by squiguy7 on Thursday August 24, 2017 @07:28PM (#15094963)
This lightning talk gives some great information on use cases for the new sync.Map: https://youtu.be/C1EtfDnsdDs
Re:Go 1.9 is released by deckarep on Friday August 25, 2017 @12:22AM (#15096100)
Wow great find!
Re:Go 1.9 is released by artursapek on Thursday August 24, 2017 @07:09PM (#15094860)
It could just be one map shared by many goroutines, which normally causes a panic:

    fatal error: concurrent map writes
Re:Go 1.9 is released by freecodyx on Thursday August 24, 2017 @07:15PM (#15094898)
i am dealing with this problem right now. also i have a big problem with deepclone,

I did a big rewrite of a current project, and clearly it was badly designed :(

Re:Go 1.9 is released by azinman2 on Thursday August 24, 2017 @09:38PM (#15095500)
Standard practice is to use a mutex to guard against concurrent usage.
Re:Go 1.9 is released by logicallee on Thursday August 24, 2017 @11:54PM (#15095987)
also necessary for reads?

Also, do you have any good references to proper best practices around concurrent and parallel programming? (in Go.) Like just basic things. Code I can copy and paste without it having obscure race conditions because that use of mutex is absolutely correct, and something that lets me understand the limitations. I feel like it is very easy to do things "wrong" or not notice some edge cases. In C++ I didn't only ever coded single-threaded for this reason. Too many gotchas. Any help would be appreciated.

Re:Go 1.9 is released by dgellow on Friday August 25, 2017 @01:07AM (#15096258)
I would suggest you to read the book "Concurrency in Go", by Katherine Cox-Budai, 2017: http://shop.oreilly.com/product/0636920046189.do
Re:Go 1.9 is released by logicallee on Friday August 25, 2017 @02:15PM (#15100840)
Thank you for the recommendation!
Re:Go 1.9 is released by carbocation on Friday August 25, 2017 @12:16AM (#15096078)
Necessary for reads unless no additional writing will be done. If you initialize/write into a map and then later have concurrent reads from it, the program will run. If you try to write in the midst of this, it will crash.
Re:Go 1.9 is released by alphaalpha101 on Thursday August 24, 2017 @11:25PM (#15095883)
I really, really don't understand why this would get downvoted. Are people not allowed to ask questions now?
Re:Go 1.9 is released by pvg on Thursday August 24, 2017 @11:42PM (#15095942)
They're discouraged from complaining about downvoting.
Re:Go 1.9 is released by alphaalpha101 on Friday August 25, 2017 @12:59AM (#15096228)
It was not a complaint, it was a question, just like my top-level comment.

Was that interpreted as a complaint as well? Is that the problem?

Re:Go 1.9 is released by pvg on Friday August 25, 2017 @05:35AM (#15097208)
It sounded like complaining but either way, take a look at these.

https://news.ycombinator.com/newsguidelines.html

"Please don't comment about the voting on comments. It never does any good, and it makes boring reading."

Re:Go 1.9 is released by issaria on Friday August 25, 2017 @04:53AM (#15097077)
A concurrent map in my understanding, is a map that can be accessed concurrently without explicit synchronization, not each coroutine has a piece of it. Check java ConcurrentHashMap.
Re:Go 1.9 is released by kraig on Thursday August 24, 2017 @07:06PM (#15094843)
or you just have two or more goroutines that need to modify a map