Here’s a fun little git I came across from Antoine Grondin. It’s a cute little logfile color package to make your logfiles really pop!
Tired of those old boring foreground on background logs? Well, try this!
1234567891011121314151617181920
packagemainimport("log""os""time""github.com/aybabtme/rgbterm/rainbow")funcmain(){joyfulOutput:=rainbow.New(os.Stderr,252,255,43)log.SetOutput(joyfulOutput)fori:=0;i<500;i++{log.Printf("This is surely going to drive you nuts!\n")time.Sleep(250*time.Millisecond)}}
Okay, that’s sure to get you screamed at if you actually used it. But a more useful package used by the rainbow package is the rgbterm package. This package lets you color any text and display it on stdout.
Here’s an example using this package:
1234567891011121314151617181920
packagemainimport("fmt""github.com/aybabtme/rgbterm")funcmain(){varr,g,buint8// pick a colorr,g,b=255,255,255// choose a wordword:="=)"// colorize it!coloredWord:=rgbterm.String(word,r,g,b,r^r,g^g,b^b)fmt.Println("Oh!",coloredWord,"hello!")}