I just started picking up Golang a couple days ago and I can't seem to figure out to break out of time.Sleep()...
I can return / break out of the for loop, but the function wont return since Sleep continues doing its thing.
I am guessing the solution is pretty simple, but I can't seem to find the answer.
func main() {
ticker := time.NewTicker(time.Second * 1)
go func() {
for i := range ticker.C {
fmt.Println("tick", i)
ticker.Stop()
break
}
}()
time.Sleep(time.Second * 10)
ticker.Stop()
fmt.Println("Hello, playground")
}
Thanks in advance!