Skip to content

Instantly share code, notes, and snippets.

@fujiwara
Created November 20, 2009 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujiwara/239255 to your computer and use it in GitHub Desktop.
Save fujiwara/239255 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
my $source = shift;
unless ($source) {
print "no source. exec goshell\n";
exec("goshell");
}
my $go = $ENV{GOARCH} eq "386" ? "8"
: $ENV{GOARCH} eq "amd64" ? "6"
: $ENV{GOARCH} eq "arm" ? "5"
: die "invalid GORACH=$ENV{GOARCH}";
(my $obj = $source) =~ s/\.go$/.${go}/;
my $compile = "${go}g";
my $link = "${go}l";
my $cmd = "./${go}.out";
system($compile, $source) == 0
and system($link, $obj) == 0
and exec($cmd, @ARGV);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment