Have a function that will read the string and it changes the color whenever inside the string there is a $ and one color. I already did this (pretty crappy and slow) but you can improve on this idea:
var awaitingColor bool
colorPrint := color.New(color.FgWhite)
for _, character := range sError {
if awaitingColor {
switch character {
case 'w':
colorPrint = color.New(color.FgWhite)
break
case 'r':
colorPrint = color.New(color.FgRed)
break
case 'y':
colorPrint = color.New(color.FgYellow)
break
case 'b':
colorPrint = color.New(color.FgBlue)
break
}
awaitingColor = false
} else if character == '$' {
awaitingColor = true
} else {
colorPrint.Print(string(character))
}
}
Have a function that will read the string and it changes the color whenever inside the string there is a $ and one color. I already did this (pretty crappy and slow) but you can improve on this idea: