On Sunday, January 1, 2017 at 4:43:32 AM UTC-7, josvazg wrote: > > I am trying to come up with a detailed definition of what a thread safe Go > program is (and is not). One that a (go) tool could check by analyzing the > code for me. >
> Otherwise: > > - > > A program is globals safe if any of this is true: > - > > There are no global variables. > - > > Globals are read only. > - > > Globals are only ever modified by the same goroutine. > - > > Globals are only accessed under the same mutex. > > Hi, creating a list of cases that are either safe or unsafe would be infinite and likely error prone as seen above. For example *"**Globals are only ever modified by the same goroutine."* is not accurate because a read during a write is a data race. I would check out the Go Memory Model[1] to get a precise understanding, while sticking to the simple well defined rule[2] that: "A data race occurs when two or more goroutines access the same variable concurrently (an access means a READ or a WRITE) and at least one of the accesses is a write." [1] https://golang.org/ref/mem [2] https://golang.org/doc/articles/race_detector.html -- 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.