diff --git a/bug/Makefile b/bug/Makefile new file mode 100644 index 0000000..57b6bfd --- /dev/null +++ b/bug/Makefile @@ -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 diff --git a/bug/main.go b/bug/main.go new file mode 100644 index 0000000..3cbaf86 --- /dev/null +++ b/bug/main.go @@ -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 +}