A script to build and run small Go programs

This simple script compiles and runs Go programs on Linux.

#!/usr/local/bin/perl
use warnings;
use strict;
my $gofile = $ARGV[0];
if (! $gofile || !-f $gofile) {
    if ($gofile && $gofile !~ /\.go$/) {
        $gofile = "$gofile.go";
        if (-f $gofile) { goto found; }
    }
    die "Can't find the file.\n";
}
found:
print "Compiling\n";
system ("8g $gofile") == 0 or die "Compilation failed.\n";
my $objfile = $gofile;
$objfile =~ s/\.go/\.8/g or die "File name mismatch.\n";
print "Linking\n";
system ("8l $objfile") == 0 or die "Link failed.\n";
print "Running\n";
system ("./8.out") == 0 or die "Run failed.\n";
It is meant for small test programs only.
Copyright © Ben Bullock 2009-2010. All rights reserved. For comments, questions, and corrections, please email Ben Bullock/ Privacy/ Disclaimer