Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import (
"fmt"
"time"
)
func main() {
count := 0
fmt.Println("Start time: ", time.Now())
time.Sleep(time.Second - time.Duration(time.Now().Nanosecond()))
next_print := time.Now()
fmt.Println("Aligned to second boundary time: ", next_print)
for {
count = count + 1
if time.Now().After(next_print) {
next_print = time.Now().Add(1 * time.Second)
fmt.Printf("Spet %v for %v cycles \n", next_print, count)
count = 0
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.