Created
September 7, 2025 14:06
-
-
Save thanethomson/8c16bd98e314ae0c71c67f01f6905590 to your computer and use it in GitHub Desktop.
Colourize Go test output with a script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -o pipefail | |
| # gocolourize - add color to go test output | |
| # usage: | |
| # ./gocolourize.sh go test ./... | |
| # | |
| $@ | awk 'BEGIN { | |
| RED="\033[31m" | |
| GREEN="\033[32m" | |
| CYAN="\033[36m" | |
| BRRED="\033[91m" | |
| BRGREEN="\033[92m" | |
| BRCYAN="\033[96m" | |
| NORMAL="\033[0m" | |
| } | |
| { color=NORMAL } | |
| /^ok / { color=BRGREEN } | |
| /^FAIL/ { color=BRRED } | |
| /^SKIP/ { color=BRCYAN } | |
| /PASS:/ { color=GREEN } | |
| /FAIL:/ { color=RED } | |
| /SKIP:/ { color=CYAN } | |
| { print color $0 NORMAL } | |
| ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment