Skip to content

Commit

Permalink
Update client.go
Browse files Browse the repository at this point in the history
capture the .(type) value and allow a bytes.Buffer
  • Loading branch information
Al S-M committed Aug 29, 2019
1 parent e581e52 commit de4d1fa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,13 @@ func (c *client) Publish(topic string, qos byte, retained bool, payload interfac
pub.Qos = qos
pub.TopicName = topic
pub.Retain = retained
switch payload.(type) {
switch p := payload.(type) {
case string:
pub.Payload = []byte(payload.(string))
pub.Payload = []byte(p)
case []byte:
pub.Payload = payload.([]byte)
pub.Payload = p
case bytes.Buffer:
pub.Payload = (payload.(bytes.Buffer)).Bytes()
pub.Payload = p.Bytes()
default:
token.setError(fmt.Errorf("Unknown payload type"))
return token
Expand Down

0 comments on commit de4d1fa

Please sign in to comment.