Skip to content
This repository was archived by the owner on Apr 30, 2019. It is now read-only.

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

Closed
@ncw

Description

@ncw

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

panic(`invalid arg: ` + reflect.TypeOf(x).String())

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions