Skip to content

Instantly share code, notes, and snippets.

@zaydek-old
Created November 12, 2019 05:51
Show Gist options
  • Save zaydek-old/ae517158fd2faa25c98871d7013acca5 to your computer and use it in GitHub Desktop.
Save zaydek-old/ae517158fd2faa25c98871d7013acca5 to your computer and use it in GitHub Desktop.
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