1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| package main
import ( "fmt" "log" )
var ( Red = Color("\033[1;31m%s\033[0m") Green = Color("\033[1;32m%s\033[0m") Yellow = Color("\033[1;33m%s\033[0m") Blue = Color("\033[1;34m%s\033[0m") Purple = Color("\033[1;35m%s\033[0m") )
func Color(color string) func(...interface{}) string { return func(args ...interface{}) string { return fmt.Sprintf(color, fmt.Sprint(args...)) } }
func main() { log.Println(Red("Red!")) log.Println(Green("Green!")) log.Println(Yellow("Yellow!")) log.Println(Blue("Blue!")) log.Println(Purple("Purple!")) }
|