gopherjs / gopherwasm

This package is deprecated. Use syscall/js of GopherJS instead.
BSD 2-Clause "Simplified" License
79 stars 5 forks source link

js.ValueOf doesn't take map[string]interface{} in gopherjs #19

Closed ncw closed 5 years ago

ncw commented 5 years ago

This bit of code is successful using wasm, but fails when run with gopherjs:

    opts := js.ValueOf(map[string]interface{}{
        "key1": "val1",
        "key2": "val2",
        "key3": "val3",
    })

Giving the error

myprogram.js:1412 Uncaught Error: invalid arg: map[string]interface {}
    at $callDeferred (myprogram.js:1412)
    at $panic (myprogram.js:1451)
    at Object.ValueOf (js_notwasm.go:187)
    at main (main.go:71)
    at $init (myprogram.js:65744)
    at $goroutine (myprogram.js:1471)
    at $runScheduled (myprogram.js:1511)
    at $schedule (myprogram.js:1527)
    at $go (myprogram.js:1503)
    at myprogram.js:65755
    at myprogram.js:65758

The panic is from this bit of code

https://github.com/gopherjs/gopherwasm/blob/491e2f5cf3e461ccc9f47e79ac430009f7e09e4d/js/js_notwasm.go#L187

I will send a PR to fix in a moment.

I note that []interface{} is missing from ValueOf compared to the go/wasm implementation such as