Skip to content

Instantly share code, notes, and snippets.

@zaydek zaydek/color.go
Created Nov 12, 2019

Embed
What would you like to do?
package main
import "fmt"
var (
Blackf = newColorf("\033[1;30m%s\033[0m")
Redf = newColorf("\033[1;31m%s\033[0m")
Greenf = newColorf("\033[1;32m%s\033[0m")
Yellowf = newColorf("\033[1;33m%s\033[0m")
Purplef = newColorf("\033[1;34m%s\033[0m")
Magentaf = newColorf("\033[1;35m%s\033[0m")
Tealf = newColorf("\033[1;36m%s\033[0m")
Whitef = newColorf("\033[1;37m%s\033[0m")
)
func newColorf(colorf string) func(string, ...interface{}) string {
fn := func(format string, args ...interface{}) string {
return fmt.Sprintf(colorf, fmt.Sprintf(format, args...))
}
return fn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.