Turning struct into javascript dictionary

32 views
Skip to first unread message

Some Body

unread,
Oct 13, 2016, 12:54:53 PM10/13/16
to GopherJS
Scenario:

type C struct {
  A bool `js:"a"`
  B bool `js:"b"`
}

c := C{A: true, B: false}
s := m.Call("method", c)

Right now when I run my code I see the following being created:

{ A: true, B: false }

but would like to see

{ a: true, b: false }

How does one do this?  Sorry if this is meant to be obvious.

Some Body

unread,
Oct 13, 2016, 10:03:37 PM10/13/16
to GopherJS
For now I am going to just use a map:

map[string]bool{"a": true, "b": true}

I am probably not understanding what the js tag is for anyway.  If somebody knows and wouldn't mind filling me in, I would appreciate it.

Paul Jolly

unread,
Oct 14, 2016, 5:01:51 AM10/14/16
to GopherJS
Hi - I'm guessing you ended up asking the question in the issues list?

Assuming so, my response here with the link above is just a signpost to the answer
Reply all
Reply to author
Forward
0 new messages