From a2754f15fc2bc2eede94e2e41712f9f0585f2426 Mon Sep 17 00:00:00 2001 From: Duco van Amstel Date: Sat, 8 Dec 2018 16:04:10 +0000 Subject: Enable errcheck linter (#646) --- bridge/sshchat/sshchat.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'bridge/sshchat/sshchat.go') diff --git a/bridge/sshchat/sshchat.go b/bridge/sshchat/sshchat.go index 827c81de..555759bf 100644 --- a/bridge/sshchat/sshchat.go +++ b/bridge/sshchat/sshchat.go @@ -30,9 +30,10 @@ func (b *Bsshchat) Connect() error { b.r = bufio.NewScanner(r) b.w = w b.r.Scan() - w.Write([]byte("/theme mono\r\n")) - b.handleSSHChat() - return nil + if _, handleErr := w.Write([]byte("/theme mono\r\n")); handleErr != nil { + return handleErr + } + return b.handleSSHChat() }) }() if err != nil { @@ -59,7 +60,9 @@ func (b *Bsshchat) Send(msg config.Message) (string, error) { b.Log.Debugf("=> Receiving %#v", msg) if msg.Extra != nil { for _, rmsg := range helper.HandleExtra(&msg, b.General) { - b.w.Write([]byte(rmsg.Username + rmsg.Text + "\r\n")) + if _, err := b.w.Write([]byte(rmsg.Username + rmsg.Text + "\r\n")); err != nil { + b.Log.Errorf("Could not send extra message: %#v", err) + } } if len(msg.Extra["file"]) > 0 { for _, f := range msg.Extra["file"] { @@ -73,13 +76,15 @@ func (b *Bsshchat) Send(msg config.Message) (string, error) { msg.Text = fi.Comment + ": " + fi.URL } } - b.w.Write([]byte(msg.Username + msg.Text)) + if _, err := b.w.Write([]byte(msg.Username + msg.Text)); err != nil { + b.Log.Errorf("Could not send file message: %#v", err) + } } return "", nil } } - b.w.Write([]byte(msg.Username + msg.Text + "\r\n")) - return "", nil + _, err := b.w.Write([]byte(msg.Username + msg.Text + "\r\n")) + return "", err } /* -- cgit v1.2.3