Skip to content

Instantly share code, notes, and snippets.

@JohnMorales
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnMorales/73e1280c962604e48273 to your computer and use it in GitHub Desktop.
Save JohnMorales/73e1280c962604e48273 to your computer and use it in GitHub Desktop.
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