There is a gocode, which is compiled into a wasm file. I want one of the functions to return an array, but when I do so I see a panic: ValueOf: invalid value
error. js.ValueOf
function seems to be able to handle an array:
...
case []interface{}:
a := arrayConstructor.New(len(x))
for i, s := range x {
a.SetIndex(i, s)
}
return a
...
but still panics, when I give it a []int
value.
package main
import (
"fmt"
"syscall/js"
)
var signal = make(chan int)
func keepAlive() {
for {
<-signal
}
}
func main() {
js.Global().Set("PanicStation", js.FuncOf(PanicStation))
keepAlive()
}
func PanicStation(this js.Value, args []js.Value) interface{} {
arr := make([]int, 1)
return arr
}