Go is generally known for having good built-in support for concurrency in Go. The solution was fixed in #2171 by using sync. It could also have been fixed without using the sync package by using an init function to set the variable v once. When the doSomething function is evaluated, running RLock / RUnlock will not affect the original lock in the User struct rendering it useless. The solution uses a pointer.
Table of contents
Concurrency in Go is hardUsing global variablesCopying structs from the sync packageUsing time.AfterConclusion1 Comment
Sort: