From 7efa4824ae1e4c321a34c55364b4ef1cd79ee628 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Sun, 15 Nov 2026 16:43:14 -0500 Subject: [PATCH] refactor: run go fix --- internal/config/config.go | 2 +- internal/kasa/discover.go | 2 +- internal/riemann/event.go | 9 +++------ internal/riemann/subscriber.go | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index dfe8489..93a9830 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -54,7 +54,7 @@ func getenvBool(key string, fallback bool) bool { func parseList(s string) []string { var items []string - for _, part := range strings.Split(s, ",") { + for part := range strings.SplitSeq(s, ",") { part = strings.TrimSpace(part) if part != "" { items = append(items, part) diff --git a/internal/kasa/discover.go b/internal/kasa/discover.go index 7c77391..84674b7 100644 --- a/internal/kasa/discover.go +++ b/internal/kasa/discover.go @@ -88,7 +88,7 @@ func BroadcastAddresses() ([]net.IP, error) { mask := ipnet.Mask if len(mask) == 4 { bcast := make(net.IP, 4) - for i := 0; i < 4; i++ { + for i := range 4 { bcast[i] = ipv4[i] | ^mask[i] } bcastStr := bcast.String() diff --git a/internal/riemann/event.go b/internal/riemann/event.go index 64294a3..00df432 100644 --- a/internal/riemann/event.go +++ b/internal/riemann/event.go @@ -1,5 +1,7 @@ package riemann +import "slices" + // Event represents an event received from Riemann via SSE or WebSocket. type Event struct { Host string `json:"host"` @@ -16,10 +18,5 @@ type Event struct { // HasTag returns true if the event has the specified tag. func (e *Event) HasTag(tag string) bool { - for _, t := range e.Tags { - if t == tag { - return true - } - } - return false + return slices.Contains(e.Tags, tag) } diff --git a/internal/riemann/subscriber.go b/internal/riemann/subscriber.go index 514ed6e..0289357 100644 --- a/internal/riemann/subscriber.go +++ b/internal/riemann/subscriber.go @@ -115,8 +115,8 @@ func (s *Subscriber) readStream(ctx context.Context, r io.Reader, out chan<- Eve continue // SSE comment or heartbeat ping } - if strings.HasPrefix(line, "data:") { - data := strings.TrimSpace(strings.TrimPrefix(line, "data:")) + if after, ok := strings.CutPrefix(line, "data:"); ok { + data := strings.TrimSpace(after) if data == "" { continue } -- knotmirror 0.0.1