> On 1 Feb 2021, at 22.05, xie cui <cuiwei...@gmail.com> wrote:
> 
> here is the code:
> package main
> 
> import "fmt"
> 
> func main() {
>       counter := 0
>       ch := make(chan struct{}, 1)
>       closeCh := make(chan struct{})
>       go func() {
>               counter++     //(1)
>               ch <- struct{}{}
>       }()
>       go func() {
>               _ = <-ch
>               fmt.Println(counter) //(2)
>               close(closeCh)
>       }()
>       _ =<-closeCh
> }
> 
> is (1) happens before (2)? why?

I believe the answer is not g. https://golang.org/ref/mem#tmp_7

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/92E42D49-9EB0-444E-AF50-D83F9BD6518E%40gmail.com.

Reply via email to