wa-lang.org/wazero@v1.0.2/internal/gojs/testdata/goroutine/main.go (about)

     1  package goroutine
     2  
     3  import "fmt"
     4  
     5  func Main() {
     6  	msg := make(chan int)
     7  	finished := make(chan int)
     8  	go func() {
     9  		<-msg
    10  		fmt.Println("consumer")
    11  		finished <- 1
    12  	}()
    13  	go func() {
    14  		fmt.Println("producer")
    15  		msg <- 1
    16  	}()
    17  	<-finished
    18  }