Thank you for your reply, I agree there should be a memory barrier for the
channel, for it is different from the other assignment statements and not a
write operation. Have you got some readings talk about this?
On Tuesday, January 7, 2020 at 10:17:43 AM UTC+8, Kurtis Rader wrote:
>
> On Mon, Ja
On Mon, Jan 6, 2020 at 5:47 PM hao dong wrote:
> thanks for your reply. Could you guide me any readings or source code
> about channel of happens before.
>
I think you have misunderstood this text in the https://golang.org/ref/mem
document you linked to:
Within a single goroutine, reads and wri
thanks for your reply. Could you guide me any readings or source code about
channel of happens before.
On Tuesday, January 7, 2020 at 3:02:30 AM UTC+8, Ian Lance Taylor wrote:
>
> On Mon, Jan 6, 2020 at 10:55 AM hao dong >
> wrote:
> >
> > After reading blog post : https://golang.org/ref/mem
On Mon, Jan 6, 2020 at 10:55 AM hao dong wrote:
>
> After reading blog post : https://golang.org/ref/mem
>
> I got one question, in the code below:
>
>
> var c = make(chan int, 10)
> var a string
>
> func f() {
> a = "hello, world"
> c <- 0
> }
>
> func main() {
> go f()
> <-c
> print(a)
> }
>
>
>
After reading blog post : https://golang.org/ref/mem
I got one question, in the code below:
var c = make(chan int, 10)
var a string
func f() {
a = "hello, world"
c <- 0
}
func main() {
go f()
<-c
print(a)
}
How can the complier knows that a = "hello,