Skip to content

Instantly share code, notes, and snippets.

@thanethomson
Created September 7, 2025 14:06
Show Gist options
  • Select an option

  • Save thanethomson/8c16bd98e314ae0c71c67f01f6905590 to your computer and use it in GitHub Desktop.

Select an option

Save thanethomson/8c16bd98e314ae0c71c67f01f6905590 to your computer and use it in GitHub Desktop.
Colourize Go test output with a script
#!/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