package log import "text/template" type Attribute int // Base attributes const ( Reset Attribute = iota Bold Faint Italic Underline BlinkSlow BlinkRapid ReverseVideo Concealed CrossedOut ) // Foreground text colors const ( FgBlack Attribute = iota + 30 FgRed FgGreen FgYellow FgBlue FgMagenta FgCyan FgWhite ) // Foreground Hi-Intensity text colors const ( FgHiBlack Attribute = iota + 90 FgHiRed FgHiGreen FgHiYellow FgHiBlue FgHiMagenta FgHiCyan FgHiWhite ) // Background text colors const ( BgBlack Attribute = iota + 40 BgRed BgGreen BgYellow BgBlue BgMagenta BgCyan BgWhite ) // Background Hi-Intensity text colors const ( BgHiBlack Attribute = iota + 100 BgHiRed BgHiGreen BgHiYellow BgHiBlue BgHiMagenta BgHiCyan BgHiWhite ) func setColorMap(funcMap template.FuncMap, color bool) { if color { funcMap["red"] = func() string { return "\033[91m" } funcMap["redl"] = func() string { return "\033[31m" } funcMap["green"] = func() string { return "\033[92m" } funcMap["yellow"] = func() string { return "\033[93m" } funcMap["blue"] = func() string { return "\033[94m" } funcMap["magenta"] = func() string { return "\033[95m" } funcMap["cyan"] = func() string { return "\033[96m" } funcMap["white"] = func() string { return "\033[97m" } funcMap["reset"] = func() string { return "\033[0m" } return } funcMap["red"] = func() string { return "" } funcMap["redl"] = func() string { return "" } funcMap["green"] = func() string { return "" } funcMap["yellow"] = func() string { return "" } funcMap["blue"] = func() string { return "" } funcMap["magenta"] = func() string { return "" } funcMap["cyan"] = func() string { return "" } funcMap["white"] = func() string { return "" } funcMap["reset"] = func() string { return "" } } // func