Color returns a string in a certain color. The first argument is a string containing the color code or a constant from the table above mapped to a code. The following will print the string "Foo" in yellow: fmt.Print(Color(Yellow, "Foo"))
(code, msg string)
| 21 | // The following will print the string "Foo" in yellow: |
| 22 | // fmt.Print(Color(Yellow, "Foo")) |
| 23 | func (m *Messenger) Color(code, msg string) string { |
| 24 | if m.NoColor { |
| 25 | return msg |
| 26 | } |
| 27 | return fmt.Sprintf("\033[%sm%s\033[m", code, msg) |
| 28 | } |