colorizing golang test run output

You can use grc, a generic colourizer, to colourize anything.

On Debian/Ubuntu, install with apt-get install grc. On a Mac with , brew install grc.

Create a config directory in your home directory:

mkdir ~/.grc

Then create your personal grc config in ~/.grc/grc.conf:

# Go
\bgo.* test\b
conf.gotest

Then create a Go test colourization config in ~/.grc/conf.gotest, such as:

regexp==== RUN .*
colour=blue
-
regexp=--- PASS: .*
colour=green
-
regexp=^PASS$
colour=green
-
regexp=^(ok|\?) .*
colour=magenta
-
regexp=--- FAIL: .*
colour=red
-
regexp=[^\s]+\.go(:\d+)?
colour=cyan

Now you can run Go tests with:

grc go test -v ./..

Sample output:

screenshot

To avoid typing grc all the time, add an alias to your shell (if using Bash, either ~/.bashrc or ~/.bash_profile or both, depending on your OS):

alias go=grc go

Now you get colourization simply by running:

go test -v ./..

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)