CLI Debugging
Ok, so maybe I’m late to the game on this one, but I’ve recently realized the value of including a clear command when I run tests. I started doing it bash a few months ago with
1 |
clear && go test |
Today I was working in windows and realized I could do the same thing with
1 |
cls & go test |
Of course, substitute “go test” for what ever language and operation you’re currently running. This significantly reduces the visual clutter and makes it much faster to iterate through debugging.
I’ll also include this here; My .bashrc when I’m working in Go includes these functions:
1 2 3 4 5 6 7 8 9 10 11 |
color()(set -o pipefail;"$@" 2>&1>&3|sed $'s,.*,\e[38;5;218m&\e[m,'>&2)3>&1 function g () { if [ -z $1 ] then clear && color go run main.go else clear && color go run $1 fi } alias gt="clear && color go test" |
The first, color(), is hard to read, but it changes the color of stderr. The rest let me use “g” as command to run main.go or “g foo.go” to run foo.go. And “gt” will run go test for the current directory.