From 9c203ef20193bb54e1fd6aaf3dd9c623f4e82d57 Mon Sep 17 00:00:00 2001 From: llaoj Date: Mon, 12 Dec 2022 09:19:30 +0800 Subject: [PATCH] For the brevity of the code, I changed the print format of arguments. --- webtty/webtty.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/webtty/webtty.go b/webtty/webtty.go index ac3f4f9..454359c 100644 --- a/webtty/webtty.go +++ b/webtty/webtty.go @@ -98,17 +98,13 @@ func (wt *WebTTY) Run(ctx context.Context) error { errs <- func() error { buffer := make([]byte, wt.bufferSize) var line string - arguments, err := json.Marshal(wt.arguments) - if err != nil { - return err - } for { n, err := wt.masterConn.Read(buffer) if err != nil { return ErrMasterClosed } - err = wt.handleMasterReadEvent(buffer[:n], &line, arguments) + err = wt.handleMasterReadEvent(buffer[:n], &line) if err != nil { return err } @@ -177,7 +173,7 @@ func (wt *WebTTY) masterWrite(data []byte) error { return nil } -func (wt *WebTTY) handleMasterReadEvent(data []byte, line *string, argument []byte) error { +func (wt *WebTTY) handleMasterReadEvent(data []byte, line *string) error { if len(data) == 0 { return errors.New("unexpected zero length read from master") } @@ -203,7 +199,7 @@ func (wt *WebTTY) handleMasterReadEvent(data []byte, line *string, argument []by // 13(ASCII) means carriage return(CR) // it is the end of a line if decodedBuffer[n-1] == 13 { - log.Printf("[write-log] %s %s\n", argument, *line) + log.Printf("[write-log] %v %s\n", wt.arguments, *line) *line = "" } }