diff --git a/utils.go b/utils.go index 2f49fb1..c4d106a 100644 --- a/utils.go +++ b/utils.go @@ -3,6 +3,7 @@ package natsio import ( "encoding/json" "fmt" + "github.com/nats-io/nats.go" "strings" "github.com/thoas/go-funk" @@ -51,3 +52,9 @@ func BytesToInterface(b []byte, dest interface{}) error { } return err } + +func MsgRespond(msg *nats.Msg, data interface{}) { + if err := msg.Respond(InterfaceToBytes(data)); err != nil { + fmt.Printf("[natsio.MsgRespond] error when response msg %s", msg.Reply) + } +}