hudly/main.go

47 lines
680 B
Go
Raw Blame History

package main
import (
"bufio"
"log"
"os"
"time"
)
const KEY = "5039a811-1b27-4db6-a7f0-c8dd28eeebcd"
func replaceCorruptedRune(msg string) string {
runes := []rune(msg)
for i, r := range runes {
if r == '<27>' {
runes[i] = '§'
}
}
return string(runes)
}
func tailFile(path string, lineCh chan<- string) {
file, err := os.Open(path)
if err != nil {
log.Fatalf("Failed to open file: %v", err)
}
defer file.Close()
file.Seek(0, 2)
reader := bufio.NewReader(file)
for {
line, err := reader.ReadString('\n')
if err != nil {
time.Sleep(100 * time.Millisecond)
continue
}
lineCh <- line
}
}
func main() {
app := NewApp(KEY)
app.Start()
}