package util import ( "bufio" "fmt" "github.com/fatih/color" "os" "strings" ) func ReadBool() bool { read := bufio.NewReader(os.Stdin) ret, _ := read.ReadByte() switch ret { case 'y': fallthrough case 'Y': return true case 'n': fallthrough case 'N': return false } return false } func ReadBoolWithMessage(message string) bool { NoNewLinePrint(color.HiRedString, message) return ReadBool() } func ReadLine() string { read := bufio.NewReader(os.Stdin) s, _ := read.ReadString('\n') return s[:len(s)-1] } func ReadLineWithMessage(message string) string { NoNewLinePrint(color.HiRedString, message) return ReadLine() } func NoNewLinePrint(f func(format string, a ...interface{}) string, message string) { if strings.HasSuffix(message, "\n") { message = message[:len(message)-1] } fmt.Printf(f(message)) }