From 0c9bc47a3a82a38f862b037b8c989c3880b4eede Mon Sep 17 00:00:00 2001 From: Chuangbo Li Date: Sun, 29 Dec 2024 06:07:32 +0800 Subject: [PATCH] refactor: simplify `startSystemUpdateTicker` using `time.Tick` (#347) According to the Go 1.23 documentation, the garbage collector can now recover unreferenced tickers created with time.Tick, making time.NewTicker method unnecessary in most cases. Reference: * time.Tick: https://pkg.go.dev/time#Tick --- beszel/internal/hub/hub.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beszel/internal/hub/hub.go b/beszel/internal/hub/hub.go index b69c8f6..ae97e06 100644 --- a/beszel/internal/hub/hub.go +++ b/beszel/internal/hub/hub.go @@ -227,8 +227,8 @@ func (h *Hub) Run() { } func (h *Hub) startSystemUpdateTicker() { - ticker := time.NewTicker(15 * time.Second) - for range ticker.C { + c := time.Tick(15 * time.Second) + for range c { h.updateSystems() } }