Skip to content

Commit c5892dd

Browse files
committed
Fix: Error return value of conn.Close is not checked
1 parent 9f774c4 commit c5892dd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ func wsHandler(w http.ResponseWriter, r *http.Request) {
170170
log.Println(err)
171171
return
172172
}
173-
defer conn.Close()
173+
defer func() {
174+
if err := conn.Close(); err != nil {
175+
log.Printf("Could not close websocket connection: %v", err)
176+
}
177+
}()
174178

175179
// Loop to read messages from the WebSocket connection.
176180
for {

0 commit comments

Comments
 (0)