Closed Like0x closed 4 years ago
Is there a way to clear the set color string?
I used color in other places, but I just want to clear the color in the specified place.
Yellow = color.New(color.FgYellow).SprintFunc() s := Yellow(str) // clear color s ?
I don't want to turn off the color globally.
var flagNoColor = flag.Bool("no-color", false, "Disable color output") if *flagNoColor { color.NoColor = true // disables colorized output }
Is there any code to do that?
Yeah create your color instance first before using SprintFunc() and then you can disable it via DisableColor(), see: https://github.com/fatih/color#disableenable-color
SprintFunc()
DisableColor()
Is there a way to clear the set color string?
I used color in other places, but I just want to clear the color in the specified place.
I don't want to turn off the color globally.
Is there any code to do that?