loading...
Cover image for Go formatting with rgblog

Go formatting with rgblog

foresthoffman profile image Forest Hoffman Updated on ・2 min read

One of my projects involves a lot of console output, and to make it readable, I added some color. Cyan for important messages, red for errors, and yellow for normal (everything is fine) logs.

The short of it is: I wanted to do the same somewhere else, so I published it.

If you're a Go developer and want some quick and easy functions to color things, check it out.

Here's the GitHub repo if you want to see the README. Or, you can just go get github.com/foresthoffman/rgblog and use it right away.

If you'd like to see what the colors would look like, without downloading the package, you can run the following in your shell:

echo -e "
\033[0;37mNormal Colors\033[0m
Black\t\033[0;30mThe quick brown fox jumped over the lazy dog\033[0m
Red\t\033[0;31mThe quick brown fox jumped over the lazy dog\033[0m
Green\t\033[0;32mThe quick brown fox jumped over the lazy dog\033[0m
Yellow\t\033[0;33mThe quick brown fox jumped over the lazy dog\033[0m
Blue\t\033[0;34mThe quick brown fox jumped over the lazy dog\033[0m
Magenta\t\033[0;35mThe quick brown fox jumped over the lazy dog\033[0m
Cyan\t\033[0;36mThe quick brown fox jumped over the lazy dog\033[0m
White\t\033[0;37mThe quick brown fox jumped over the lazy dog\033[0m

\033[1;37mBold/Bright Colors\033[0m
Black\t\033[1;30mThe quick brown fox jumped over the lazy dog\033[0m
Red\t\033[1;31mThe quick brown fox jumped over the lazy dog\033[0m
Green\t\033[1;32mThe quick brown fox jumped over the lazy dog\033[0m
Yellow\t\033[1;33mThe quick brown fox jumped over the lazy dog\033[0m
Blue\t\033[1;34mThe quick brown fox jumped over the lazy dog\033[0m
Magenta\t\033[1;35mThe quick brown fox jumped over the lazy dog\033[0m
Cyan\t\033[1;36mThe quick brown fox jumped over the lazy dog\033[0m
White\t\033[1;37mThe quick brown fox jumped over the lazy dog\033[0m
"

In mine it looks like this:

Cheers!

Posted on by:

foresthoffman profile

Forest Hoffman

@foresthoffman

Full Stack Engineer. Golang Engineer at The Home Depot. Musings about Go, TypeScript, Node.js. My thoughts are my own.

Discussion

markdown guide