Skip to content

Instantly share code, notes, and snippets.

@mjudeikis
Created December 1, 2019 17:34
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 mjudeikis/98bd445b25d85253f3557b9f0492558b to your computer and use it in GitHub Desktop.
Save mjudeikis/98bd445b25d85253f3557b9f0492558b to your computer and use it in GitHub Desktop.
package main
import (
"bufio"
"os"
"time"
tm "github.com/buger/goterm"
"github.com/sirupsen/logrus"
"github.com/chbmuc/cec")
var (
log *logrus.Entry
)
func init() {
logger := logrus.New()
logger.Formatter = &logrus.TextFormatter{FullTimestamp: true}
logger.SetLevel(logrus.DebugLevel)
log = logrus.NewEntry(logger)
}
func run() error {
log.Info("start demo app")
tty, err := os.OpenFile("/dev/tty0", os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm)
if err != nil {
return err
}
tm.Output = bufio.NewWriter(tty)
tm.Clear()
for {
log.Info("print...")
// By moving cursor to top-left position we ensure that console output
// will be overwritten each time, instead of adding new.
tm.MoveCursor(10, 10)
tm.Println("Current Time:", time.Now().Format(time.RFC1123))
tm.Flush() // Call it every time at the end of rendering
time.Sleep(time.Second)
}
}
func main() {
err := run()
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment