1 //go:build mage 2 // +build mage 3 4 package main 5 6 import ( 7 "io" 8 "os" 9 10 "github.com/fatih/color" 11 ) 12 13 var ( 14 ourStdout = cw{c: color.New(color.FgGreen), o: os.Stdout} 15 ourStderr = cw{c: color.New(color.FgRed), o: os.Stderr} 16 ) 17 18 // hack around color.Color not implementing Write() 19 type cw struct { 20 c *color.Color 21 o io.Writer 22 } 23 24 func (cw cw) Write(p []byte) (int, error) { 25 i := len(p) 26 _, err := cw.c.Fprint(cw.o, string(p)) // discarding the number of bytes written for now... 27 return i, err 28 } 29