Skip to content

Commit

Permalink
v2.0.0-alpha.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mohemohe committed Feb 26, 2022
1 parent 5bbf566 commit eb8ba5f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (this *LxCommon) Listen(event *chan *lxtypes.Event) {
}

func (this *LxCommon) Send(message *lxtypes.Event) {
m, err := ToMap(message)
m, err := ToJSON(message)
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
Expand All @@ -52,7 +52,7 @@ func (this *LxCommon) Send(message *lxtypes.Event) {

func (this *LxCommon) Close() {
message := lxtypes.NewEvent(lxtypes.CloseEvent, nil)
m, err := ToMap(message)
m, err := ToJSON(message)
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
Expand Down
8 changes: 8 additions & 0 deletions common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ func ToMap(i interface{}) (lxtypes.M, error) {
}
return r, nil
}

func ToJSON(i interface{}) (string, error) {
j, err := json.Marshal(i)
if err != nil {
return "", err
}
return string(j), nil
}

0 comments on commit eb8ba5f

Please sign in to comment.