rpcclient: Update for go1.10 breaking changes.

Go 1.10 made some changes such that json.Unmarshal can no longer
unmarshal into exported fields that are themselves embedded via an
uninitialized unexported pointer.

Since rpcclient previously relied on this behavior, this updates the
client to create the pointers before unmarshalling into the struct.
This commit is contained in:
Dave Collins 2018-02-19 18:36:29 -06:00 committed by Dave Collins
parent 1cd648d784
commit 2be2f12b35

View File

@ -310,6 +310,8 @@ func (c *Client) handleMessage(msg []byte) {
// Attempt to unmarshal the message as either a notification or
// response.
var in inMessage
in.rawResponse = new(rawResponse)
in.rawNotification = new(rawNotification)
err := json.Unmarshal(msg, &in)
if err != nil {
log.Warnf("Remote server sent invalid message: %v", err)