This is rather simple, but I can't figure it out...
I am trying to make a time.Tick every seconds... but it ticks every 2 seconds?!?
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("Hello, playground")
iterationIndex := 0
tick := time.Tick(time.Second)
done := make(chan bool, 1)
for _ = range tick {
select {
case <-tick:
iterationIndex++
if iterationIndex >= 10{
done <- true
}
fmt.Printf("%s\n", time.Now().Format("15:04:05.000000"))
case <-done:
return
}
}
}
links to go playground https://play.golang.org/p/WKhnNK2BRpd