<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Robo &#187; Shell Scripts</title>
	<atom:link href="http://robinramael.com/category/messing-around/shell-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://robinramael.com</link>
	<description>is mostly harmless</description>
	<lastBuildDate>Tue, 13 Dec 2011 13:02:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='robinramael.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Robo &#187; Shell Scripts</title>
		<link>http://robinramael.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://robinramael.com/osd.xml" title="Robo" />
	<atom:link rel='hub' href='http://robinramael.com/?pushpress=hub'/>
		<item>
		<title>Scripting the Go-compiler</title>
		<link>http://robinramael.com/2009/11/17/scripting-the-go-compiler/</link>
		<comments>http://robinramael.com/2009/11/17/scripting-the-go-compiler/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 23:40:10 +0000</pubDate>
		<dc:creator>Robin Ramael</dc:creator>
				<category><![CDATA[Messing around]]></category>
		<category><![CDATA[Shell Scripts]]></category>

		<guid isPermaLink="false">http://robinramael.com/?p=87</guid>
		<description><![CDATA[A good programmer is a lazy one, the cliche says. Maybe. An easily distracted one if nothing else. While trying out Google&#8217;s newly released compiled language Go, it bothered me that there was not a faster way to compile, link and execute the little programs I was writing. So, rather than to teach myself something [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robinramael.com&amp;blog=9238627&amp;post=87&amp;subd=robinramael&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A good programmer is a lazy one, the cliche says. Maybe.  An easily distracted one if nothing else. While trying out <a href="http://golang.org/">Google&#8217;s newly released compiled language Go</a>, it bothered me that there was not a faster way to compile, link and execute the little programs I was writing. So, rather than to teach myself something actually useful i wrote a script to do this all at once.</p>
<p>It is invoked by goc (best move it to /usr/bin first), the file to compile and then the arguments to give the program when it executes.</p>
<p>The -s flag will try and mute all compile and linking errors and the -m flag will rename the executable to whatever your .go file&#8217;s name was.</p>
<p>You can download it <a href="http://dl.getdropbox.com/u/244025/goc">here</a>. Sourcecode after the jump.</p>
<p><span id="more-87"></span></p>
<p><pre class="brush: bash;">

#!/bin/bash
# goc
# by Robin Ramael, no rights reserved whatsoever.
# compiles, links and executes small go-programs
# for larger programs use makefiles
# usage: goc [-s silent: tries not to output errors, only the compiled program's output]
#	 [-m rename the output program to the name of the .go file, without this flag the binary will be called 6.out]
#	 &lt;file to compile; link and execute&gt;
#	 &lt;arguments to give to the program on output&gt;
#argument mumbo-jumbo
silent=
move=
while getopts 'sm:' OPTION
do
case $OPTION in
s) silent=1
;;
m) move=1
;;
?) printf &quot;usage: goc [-s] [-m] file&quot;
esac
done
if [[ $silent ]]; then
shift 1
fi
if [[ $move ]]; then
shift 1
fi
tocomp=$1
shift 1
#$* are now the arguments we want to give our program
#/argument mumbo-jumbo
#clean up so we avoid weird errors
rm -f  6.out
# if the -s argument is given, don't output error
if [[ &quot;$silent&quot; ]]; then
6g $tocomp &gt;&gt; /dev/null
echo $tocomp | sed 's/\.go/\.6/' | xargs 6l &gt;&gt; /dev/null
else
6g $tocomp
echo $tocomp | sed 's/\.go/\.6/' | xargs 6l
fi
if [[ -e 6.out ]]; then
./6.out $*
if [[ &quot;$move&quot; ]]; then
cp 6.out `echo $tocomp | sed 's/\.go//'`
fi
fi
#clean up
echo $tocomp | sed 's/\.go/\.6/' | xargs rm
rm 6.out
</pre></p>
<p>Note that the go compiler will always overwrite or remove the 6.out file in the current directory, even if the -m flag is raised.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robinramael.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robinramael.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robinramael.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robinramael.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robinramael.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robinramael.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robinramael.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robinramael.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robinramael.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robinramael.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robinramael.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robinramael.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robinramael.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robinramael.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robinramael.com&amp;blog=9238627&amp;post=87&amp;subd=robinramael&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robinramael.com/2009/11/17/scripting-the-go-compiler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/aa9576161bb251ce62ead1d545c203fa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Robin Ramael</media:title>
		</media:content>
	</item>
	</channel>
</rss>
