Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the Windows, press Ctrl+C, the characters in the cmd.exe are displayed in incorrect colors. #205

Open
hcbb199 opened this issue Aug 21, 2023 · 0 comments

Comments

@hcbb199
Copy link

hcbb199 commented Aug 21, 2023

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)))
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant