go - Golang RethinkDB ChangeFeed Structure -


i wondering if explain how unmarshal changefeed cursor value specific struct type.

var message map[string]interface{}  chatfeedcursor.next(&message) {     fmt.println(message) } 

map[new_val:map[club_id:ea2eb6e2-755f-4dad-922d-e3693b6e55c6 date:2017-04-07 14:48:17.714 +0100 +01:00 id:e389ab54-963e-4b33-9b34-adcb6ec5b17e message:what meaning of life? user_id:00ff679f-9421-4b8b-ae7f-d11cf2adaee2] old_val:]

however, response mapped struct chatmessage.

update:

i've tried:

var message chatmessage 

however, doesn't seem of data gets set in struct.

{ 0001-01-01 00:00:00 +0000 utc}

my struct:

type chatmessage struct {     id      string        `json:"id" gorethink:"id,omitempty"`     userid      string    `json:"user_id" gorethink:"user_id"`     clubid      string    `json:"club_id" gorethink:"club_id"`     message     string    `json:"message" gorethink:"message"`     date    time.time     `json:"date" gorethink:"date"` } 

thanks.

i figured out!

the problem didn't specify field on rethinkdb change request.

previous code:

chatfeedcursor, _ := gorethink.table("club_chat").changes().run(gorethinksession) 

working code:

chatfeedcursor, _ := gorethink.table("club_chat").changes().field("new_val").run(gorethinksession) 

now .next() value maps struct no issues.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -