mirror of
https://github.com/taigrr/wasm-experiments
synced 2025-01-18 04:03:21 -08:00
Add example of getReader bug
This commit is contained in:
parent
5b0c630b59
commit
f6afc46304
7
bug/Makefile
Normal file
7
bug/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
build: clean compile
|
||||
|
||||
clean:
|
||||
rm -f ../html/test.wasm
|
||||
|
||||
compile:
|
||||
GOOS=js GOARCH=wasm GOROOT=$(GOPATH)/src/github.com/neelance/go/ $(GOPATH)/src/github.com/neelance/go/bin/go build -o ../html/test.wasm main.go
|
20
bug/main.go
Normal file
20
bug/main.go
Normal file
@ -0,0 +1,20 @@
|
||||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"syscall/js"
|
||||
"syscall/js/callback"
|
||||
)
|
||||
|
||||
func main() {
|
||||
wait := make(chan struct{})
|
||||
promise := js.Global.Call("fetch", "https://api.github.com")
|
||||
promise.Call("then", callback.New(func(args []js.Value) {
|
||||
response := args[0]
|
||||
r := response.Get("body").Call("getReader")
|
||||
r.Call("read")
|
||||
close(wait)
|
||||
}).Value)
|
||||
<-wait
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user