Multitasking, Golang, Software Development, Concurrency, Parallel Computing.
PeriodicTask runs someTask every 1 second. // If canceled goroutine should be stopped. func PeriodicTask(ctx context.Context) { // Create a new ticker with a period of 1 second. ticker := time.NewTicker(time.Second) for { select { case <-ticker.C: someTask() case <-ctx.Done(): fmt.Println("stopping