From f47bee37b0c779a29420e8bd18e81cecfa3b42ca Mon Sep 17 00:00:00 2001 From: "5684185+vsariola@users.noreply.github.com" <5684185+vsariola@users.noreply.github.com> Date: Fri, 20 Jun 2025 14:49:07 +0300 Subject: [PATCH] style(tracker): clean up Alerts Push and Pop --- tracker/alert.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tracker/alert.go b/tracker/alert.go index 93d19df..480d749 100644 --- a/tracker/alert.go +++ b/tracker/alert.go @@ -96,15 +96,17 @@ func (m *Alerts) AddAlert(a Alert) { } func (m *Alerts) Push(x any) { + if _, ok := x.(Alert); !ok { + panic("invalid type for Alerts.Push, expected Alert") + } m.alerts = append(m.alerts, x.(Alert)) } func (m *Alerts) Pop() any { - old := m.alerts - n := len(old) - x := old[n-1] - m.alerts = old[0 : n-1] - return x + n := len(m.alerts) + last := m.alerts[n-1] + m.alerts = m.alerts[:n-1] + return last } func (m Alerts) Len() int { return len(m.alerts) }