36 lines
590 B
Go
36 lines
590 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"runtime"
|
|
"strings"
|
|
)
|
|
|
|
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")
|
|
|
|
// I hate Windows
|
|
case "windows":
|
|
in := bufio.NewReader(os.Stdin)
|
|
lineNew, err := in.ReadString('\r')
|
|
catchErr(err)
|
|
line = strings.Trim(lineNew, "\r")
|
|
}
|
|
return line
|
|
}
|
|
|
|
func catchErr(err error) (errHappened bool) {
|
|
errHappened = false
|
|
if err != nil {
|
|
//fmt.Println(err)
|
|
errHappened = true
|
|
}
|
|
return errHappened
|
|
}
|