Skip to content

Commit

Permalink
server/run: return val using json encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
joshi4 committed Jun 13, 2024
1 parent 8ae8805 commit 0b0b602
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions server/run/run.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package run

import (
"bufio"
"context"
"encoding/json"
"errors"
Expand Down Expand Up @@ -189,11 +188,7 @@ func (rs *RunServer) handleCommand(cmd string, c net.Conn) {
response.Index = rs.currIndex
rs.mu.Unlock()
rs.logger.Debug("fetching command", "command", cmd)
bs, _ := json.Marshal(response)
bs = append(bs, '\n')
writer := bufio.NewWriter(c)
writer.Write(bs)
writer.Flush()
json.NewEncoder(c).Encode(response)
default:
rs.logger.Debug("unknown command", "command", cmd)
}
Expand Down

0 comments on commit 0b0b602

Please sign in to comment.