diff --git a/Makefile b/Makefile index 006d729..a0ff802 100644 --- a/Makefile +++ b/Makefile @@ -17,3 +17,5 @@ generate: sqlc generate -f sql/sqlc.yaml protoc -I=pkg/pb/ --go_out=pkg/ pkg/pb/stillbox.proto +lint: + golangci-lint run diff --git a/cmd/calls/audio.go b/cmd/calls/audio.go index 912edf8..0b41067 100644 --- a/cmd/calls/audio.go +++ b/cmd/calls/audio.go @@ -61,7 +61,10 @@ func (p *Player) playMP3(audio []byte) error { } var player = p.ctx.NewPlayer() - player.Write(data) + _, err = player.Write(data) + if err != nil { + return err + } <-time.After(time.Second) diff --git a/pkg/gordio/admin/admin.go b/pkg/gordio/admin/admin.go index 758951a..f81f7e4 100644 --- a/pkg/gordio/admin/admin.go +++ b/pkg/gordio/admin/admin.go @@ -50,6 +50,9 @@ func AddUser(ctx context.Context, username, email string, isAdmin bool) error { } hashpw, err := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.DefaultCost) + if err != nil { + return err + } _, err = db.CreateUser(context.Background(), database.CreateUserParams{ Username: username, @@ -97,6 +100,9 @@ func Passwd(ctx context.Context, username string) error { } hashpw, err := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.DefaultCost) + if err != nil { + return err + } return db.UpdatePassword(context.Background(), username, string(hashpw)) } diff --git a/pkg/gordio/nexus/websocket.go b/pkg/gordio/nexus/websocket.go index 1ec79b4..f1c6301 100644 --- a/pkg/gordio/nexus/websocket.go +++ b/pkg/gordio/nexus/websocket.go @@ -94,10 +94,12 @@ func (conn *wsConn) readPump(ctx context.Context, reg Registry, c Client) { }() conn.SetReadLimit(maxMessageSize) - conn.SetReadDeadline(time.Now().Add(pongWait)) + err := conn.SetReadDeadline(time.Now().Add(pongWait)) + if err != nil { + log.Error().Err(err).Msg("SetReadDeadline") + } conn.SetPongHandler(func(string) error { - conn.SetReadDeadline(time.Now().Add(pongWait)) - return nil + return conn.SetReadDeadline(time.Now().Add(pongWait)) }) for { _, message, err := conn.ReadMessage() @@ -125,10 +127,16 @@ func (conn *wsConn) writePump() { for { select { case msg, ok := <-conn.out: - conn.SetWriteDeadline(time.Now().Add(writeWait)) + err := conn.SetWriteDeadline(time.Now().Add(writeWait)) + if err != nil { + log.Error().Err(err).Msg("SetWriteDeadline") + } if !ok { // nexus closed us - conn.WriteMessage(websocket.CloseMessage, []byte{}) + err := conn.WriteMessage(websocket.CloseMessage, []byte{}) + if err != nil { + log.Error().Err(err).Msg("writing close message") + } return } @@ -145,7 +153,10 @@ func (conn *wsConn) writePump() { return } case <-pingTicker.C: - conn.SetWriteDeadline(time.Now().Add(writeWait)) + err := conn.SetWriteDeadline(time.Now().Add(writeWait)) + if err != nil { + log.Error().Err(err).Msg("SetWriteDeadline") + } if err := conn.WriteMessage(websocket.PingMessage, nil); err != nil { log.Debug().Err(err).Msg("x ping failed") return @@ -162,7 +173,7 @@ func (conn *wsConn) writeMessage(w io.WriteCloser, msg *pb.Message) { return } - w.Write(packed) + _, _ = w.Write(packed) } packWrite(msg) diff --git a/pkg/gordio/server/server.go b/pkg/gordio/server/server.go index 0ab41a8..ca17d63 100644 --- a/pkg/gordio/server/server.go +++ b/pkg/gordio/server/server.go @@ -61,6 +61,5 @@ func (s *Server) Go() error { go s.nex.Go(ctx) - http.ListenAndServe(s.conf.Listen, s.r) - return nil + return http.ListenAndServe(s.conf.Listen, s.r) } diff --git a/pkg/gordio/sources/http.go b/pkg/gordio/sources/http.go index c8dfe7d..8f2c938 100644 --- a/pkg/gordio/sources/http.go +++ b/pkg/gordio/sources/http.go @@ -124,7 +124,7 @@ func (h *RdioHTTP) routeCallUpload(w http.ResponseWriter, r *http.Request) { log.Info().Int("system", cur.System).Int("tgid", cur.Talkgroup).Msg("ingested") - w.Write([]byte("Call imported successfully.")) + _, _ = w.Write([]byte("Call imported successfully.")) } func (car *callUploadRequest) fill(r *http.Request) error {