Use tickers instead of for loops with sleep, replace interface{} with any

This commit is contained in:
eleksir
2025-03-28 02:34:32 +03:00
parent 40eaac419d
commit b8b9ba2c2c
9 changed files with 31 additions and 33 deletions

View File

@@ -7,7 +7,9 @@ import (
// UpdateClock get and updates (on i3bar) info about system clock.
func (c *MyConfig) UpdateClock() {
for {
ticker := time.NewTicker(time.Second * 1)
for range ticker.C {
currentTime := time.Now()
hours, minutes, _ := currentTime.Clock()
year, month, day := currentTime.Date()
@@ -21,7 +23,5 @@ func (c *MyConfig) UpdateClock() {
c.Values.ClockTime = myclock
c.Channels.UpdateReady <- true
}
time.Sleep(1 * time.Second)
}
}