package main import ( "bufio" "fmt" "os" "runtime" "strings" ) func catchErr(err error) (errHappened bool) { errHappened = false if err != nil { errHappened = true fmt.Println(err) os.Exit(2) } return errHappened } func clear() { fmt.Print("\033[H\033[2J") } func scanLine() (line string) { switch runtime.GOOS { case "linux": in := bufio.NewReader(os.Stdin) lineNew, err := in.ReadString('\n') catchErr(err) line = strings.Trim(lineNew, "\n") case "windows": in := bufio.NewReader(os.Stdin) lineNew, err := in.ReadString('\r') catchErr(err) line = strings.Trim(lineNew, "\r") } return line }