go for ticker

package main

import (
    "fmt"
    "time"
)

func main() {
    // Create a new ticker that ticks every 500 milliseconds.
    ticker := time.NewTicker(500 * time.Millisecond)

    // Create a channel to receive ticks from the ticker.
    tickerChannel := ticker.C

    // Create a goroutine to handle the ticks from the ticker.
    go func() {
        for {
            // Wait for a tick to occur.
            <-tickerChannel

            // Perform the desired action on each tick.
            fmt.Println("Tick at", time.Now())
        }
    }()

    // Run the program for 3 seconds.
    time.Sleep(3 * time.Second)

    // Stop the ticker after 3 seconds.
    ticker.Stop()
}