Explorar o código

Terminal color

Signed-off-by: Vishal Rana <vr@labstack.com>
Vishal Rana %!s(int64=10) %!d(string=hai) anos
pai
achega
0a4bf94ad3
Modificáronse 1 ficheiros con 23 adicións e 0 borrados
  1. 23 0
      color/color.go

+ 23 - 0
color/color.go

@@ -0,0 +1,23 @@
+package utils
+
+import "fmt"
+
+var (
+	Red     = outer(31)
+	Green   = outer(32)
+	Yellow  = outer(33)
+	Blue    = outer(34)
+	Magenta = outer(35)
+	Cyan    = outer(36)
+	White   = outer(37)
+)
+
+type (
+	inner func(m interface{}) string
+)
+
+func outer(n int) inner {
+	return func(m interface{}) string {
+		return fmt.Sprintf("\033[%dm%v\033[0m", n, m)
+	}
+}