Skip to content

Instantly share code, notes, and snippets.

@nanoninja
Last active July 22, 2017 14:48
Show Gist options
  • Save nanoninja/2c3f3e8ecdd238472c4ccceb33f3e2c4 to your computer and use it in GitHub Desktop.
Save nanoninja/2c3f3e8ecdd238472c4ccceb33f3e2c4 to your computer and use it in GitHub Desktop.
Go Time Display Using Ticker
package main
import (
"fmt"
"time"
)
func main() {
TimeDisplay(true)
}
func TimeDisplay(blinkSep bool) {
for _ = range time.NewTicker(time.Second).C {
n, sep := time.Now(), ""
if blinkSep && n.Second()%2 == 1 {
sep = " "
} else {
sep = ":"
}
fmt.Printf("\r%d%s%02d%s%02d ", n.Hour(), sep, n.Minute(), sep, n.Second())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment