package l import "fmt" var color colors type colors struct{} // can't use `` const ansi string = "\x1b[%dm%s\x1b[0m" const ( color_red = uint8(iota + 91) color_green color_yellow color_blue ) func (c *colors) Red(s string) string { return fmt.Sprintf(ansi, color_red, s) } func (c *colors) Yellow(s string) string { return fmt.Sprintf(ansi, color_yellow, s) } func (c *colors) Blue(s string) string { return fmt.Sprintf(ansi, color_blue, s) } func (c *colors) Green(s string) string { return fmt.Sprintf(ansi, color_green, s) } func (c *colors) autoPaint(level string) string { colorLevel := "" switch level { case "INFO": colorLevel = c.Blue(level) case "ERROR": colorLevel = c.Red(level) case "WARN": colorLevel = c.Yellow(level) case "DEBUG": colorLevel = c.Green(level) default: colorLevel = level } return colorLevel }