This adds an experimental package gojs which implements the host side of Wasm compiled by GOARCH=wasm GOOS=js go build -o X.wasm X.go This includes heavy disclaimers, in part inherited by Go's comments https://github.com/golang/go/blob/go1.19/src/syscall/js/js.go#L10-L11 Due to this many will still use TinyGo instead. That said, this is frequently asked for and has interesting features including reflection and HTTP client support. Signed-off-by: Adrian Cole <adrian@tetrate.io>
19 lines
235 B
Go
19 lines
235 B
Go
package goroutine
|
|
|
|
import "fmt"
|
|
|
|
func Main() {
|
|
msg := make(chan int)
|
|
finished := make(chan int)
|
|
go func() {
|
|
<-msg
|
|
fmt.Println("consumer")
|
|
finished <- 1
|
|
}()
|
|
go func() {
|
|
fmt.Println("producer")
|
|
msg <- 1
|
|
}()
|
|
<-finished
|
|
}
|