Last active
August 29, 2015 14:19
-
-
Save JohnMorales/73e1280c962604e48273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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