add func ToByteso
This commit is contained in:
parent
e2b22676d4
commit
756352eb19
10
utils.go
10
utils.go
|
@ -1,6 +1,7 @@
|
|||
package natsio
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/thoas/go-funk"
|
||||
|
@ -40,3 +41,12 @@ func GenerateJetStreamSubject(server, service, subject string) string {
|
|||
func GenerateReqrepSubject(server, service, subject string) string {
|
||||
return fmt.Sprintf("%s.reqrep.%s.%s.%s", globalConfig.StreamName, server, service, subject)
|
||||
}
|
||||
|
||||
// ToBytes ...
|
||||
func ToBytes(data interface{}) []byte {
|
||||
b, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
fmt.Printf("[natsio.ToBytes] error: %v with data: %v\n", err, data)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue