In the Windows, press Ctrl+C, the characters in the cmd.exe are displayed in incorrect colors.
Opened this issue · 0 comments
hcbb199 commented
If you press Ctrl+C when waiting for user input during interaction, the color of the output characters in cmd.exe is incorrect.
package main
import (
"bufio"
"github.com/fatih/color"
"os"
"strings"
)
var (
Info = color.New(color.Bold, color.FgHiGreen)
Error = color.New(color.Bold, color.FgHiRed)
)
func main() {
Info.Println("input your color: ")
reader := bufio.NewReader(os.Stdin)
input, _, err := reader.ReadLine()
if err != nil {
Error.Println(err.Error())
return
}
Info.Println("your input is " + strings.TrimSpace(string(input)))
}