-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
There is a function errorMsg which prints to the stderr stream when there is an error. In production open must never print to stderr because it may conflict with other things present in the product, and can cause debugging to become very hard.
For example, the below code can be turned into:
// roundOffTitleColor rounds off 24 bit Color to the terminals maximum color capacity for Title.
func (b Box) roundOffTitleColor(col color.RGBColor, title string) string {
switch detectTerminalColor() {
case terminfo.ColorLevelNone:
errorMsg("[warning]: terminal does not support colors, using no effects")
return title
case terminfo.ColorLevelMillions:
return col.Sprint(title)
default:
return col.C256().Sprint(title)
}
}// roundOffTitleColor rounds off 24 bit Color to the terminals maximum color capacity for Title.
func (b Box) roundOffTitleColor(col color.RGBColor, title string) (string, err) {
switch detectTerminalColor() {
case terminfo.ColorLevelNone:
return title, errors.New("terminal does not support colors")
case terminfo.ColorLevelMillions:
return col.Sprint(title), nil
default:
return col.C256().Sprint(title), nil
}
}then, do the changes as per the need.
This is a very breaking change so this has to be some with cautious.
Metadata
Metadata
Assignees
Labels
No labels