🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

github.com/aybabtme/color

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/aybabtme/color

Source
Go
Version
v0.0.0-20140713052517-28ad4cc941d6
Version published
Created
Source

This library is boring, use rgbterm

Package color

Colorize your terminal strings.

fmt.Printf("I'm in a %s world!\n", brush.Blue("blue"))

Usage

Default Brush are available for your convenience. You can invoke them directly

fmt.Printf("This is %s\n", brush.Red("red"))

... or you can create new ones!

weird := color.NewBrush(color.PurplePaint, color.CyanPaint)
fmt.Printf("This color is %s\n", weird("weird"))

Create a Style, which has some convenience methods :

redBg := color.NewStyle(color.RedPaint, color.YellowPaint)

Style.WithForeground or WithBackground returns a new Style, with the applied Paint. Styles are immutable so the original one is left unchanged

greenFg := redBg.WithForeground(color.GreenPaint)

// Style.Brush gives you a Brush that you can invoke directly to colorize strings.
green := greenFg.Brush()
fmt.Printf("This is %s but not really\n", green("kind of green"))

You can use it with all sorts of things :

sout := log.New(os.Stdout, "["+brush.Green("OK").String()+"]\t", log.LstdFlags)
serr := log.New(os.Stderr, "["+brush.Red("OMG").String()+"]\t", log.LstdFlags)

sout.Printf("Everything was going %s until...", brush.Cyan("fine"))
serr.Printf("%s killed %s !!!", brush.Red("Locke"), brush.Blue("Jacob"))

That's it!

Demo

A coloured terminal

Docs

GoDoc! (↫ this is a link)

FAQ

Does it work on Windows?

NO!

It's spelled "colour"

NO!

You're canadian, spell it "colour"

NO!

FAQs

Package last updated on 13 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts