Friday, July 1, 2011

Go Language Compile/Link/Launch Script

I've started playing around with the Go language and I think it's pretty neat. I have a security-related project I'm working on to help me learn the language that I'll share soon after it's finished.

I found myself slightly annoyed when I would compile, link, and launch my program while editing it. It was fast but the command line was long:
bin/6g whatever.go && bin/6l -o whatever whatever.6 && ./whatever -arg1 blah -arg2
To make things a little easier when switching between source files I wrote a simple script:
#!/bin/bash
#gogogo.sh <program_name> [<args>]

progname=${1}
shift
bin/6g ${progname}.go && bin/6l -o ${progname} ${progname}.6 && ./${progname} ${@}
Now just run:
./gogogo.sh whatever -arg1 blah -arg2
There's probably a smarter way using gomake or something similar but I haven't dug it up yet.