Adam Colton

What I've learned so far

  • About
  • Code
  • Cooking

terminal

CLI Debugging

November 17, 2015 by adam Leave a Comment

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

Shell
1
clear && go test

Today I was working in windows and realized I could do the same thing with

MS DOS
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:

Shell
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.

Posted in: Code Tagged: debugging, golang, terminal

We're Adopting!
GitHub
State Transition

Recent Posts

  • Mancala
  • You SHOULD learn to code
  • CLI Debugging
  • Cake Decoration
  • Pizza Sauce

Categories

  • Code
  • Cooking

Copyright © 2025 Adam Colton.

Alpha WordPress Theme by themehall.com