<?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/"
	>

<channel>
	<title>Continuous Reconsideration &#187; go</title>
	<atom:link href="http://carinae.net/tag/go/feed/" rel="self" type="application/rss+xml" />
	<link>http://carinae.net</link>
	<description>Carlos Vara&#039;s writings about software development</description>
	<lastBuildDate>Mon, 05 Jul 2010 21:08:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=9565</generator>
		<item>
		<title>First steps with Go in Ubuntu Karmic</title>
		<link>http://carinae.net/2009/11/first-steps-with-go-in-ubuntu-karmic/</link>
		<comments>http://carinae.net/2009/11/first-steps-with-go-in-ubuntu-karmic/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 23:07:02 +0000</pubDate>
		<dc:creator>Carlos Vara</dc:creator>
				<category><![CDATA[go]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://carinae.net/?p=64</guid>
		<description><![CDATA[It's all over the Internet today, Google has released a new programming language called Go. As of what I have been able to see so far, Go can be described as a systems language which aims to leverage Python's expressiveness into the grounds of compiled languages as C++. Also, Go is both fast to compile [...]]]></description>
			<content:encoded><![CDATA[<p>It's all over the Internet today, Google has released a new programming language called <a href="http://golang.org">Go</a>. As of what I have been able to see so far, Go can be described as a systems language which aims to leverage Python's expressiveness into the grounds of compiled languages as C++. Also, Go is both fast to compile and to execute. You can see some pretty impressive footage of <a href="http://www.youtube.com/watch?v=wwoWei-GAPo">Go's compiler speed in this video</a>.</p>
<p>A good starting point for Go is that it's Open Source, so you can start playing with it right now (as long as you are a linux or mac user). That's what I have done, and I'm posting my first steps under Ubuntu Karmic in case it can help anybody.</p>
<h3>Installation</h3>
<p>Go's compiler and tools are currently distributed in source, so you will first need to ensure that you have certain compiling packages installed in your system so you will be able to compile Go's tools. Also, Google uses Mercurial for revision control, so you will need it for checking out Go's tree.</p>
<p>Execute the following in a shell:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mercurial <span style="color: #c20cb9; font-weight: bold;">bison</span> <span style="color: #c20cb9; font-weight: bold;">gcc</span> libc6-dev <span style="color: #c20cb9; font-weight: bold;">ed</span></pre></div></div>

<p>And you will have all what you need to fetch and build Go's sources. We will install it in a clean way so everything is under one directory and maintenance and an eventual removal is easy. First, you need to create the directory where everything Go-related will go:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>golang</pre></div></div>

<p>Now, you need to edit your .bashrc file. It's located at the root of your home directory. Add the following lines at its end (you will have to change the GOARCH variable to <code>amd64</code> if you are running the 64bit version):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Go Installation</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GOROOT</span>=~<span style="color: #000000; font-weight: bold;">/</span>golang
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GOOS</span>=linux
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GOARCH</span>=<span style="color: #000000;">386</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GOBIN</span>=<span style="color: #800000;">${GOROOT}</span><span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #007800;">PATH</span>=<span style="color: #800000;">${PATH}</span>:<span style="color: #800000;">${GOBIN}</span>
<span style="color: #7a0874; font-weight: bold;">export</span> PATH</pre></div></div>

<p>With that in place, open a new terminal so your .bashrc gets reloaded. Within that terminal, check out Go's sources with Mercurial by typing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hg clone <span style="color: #660033;">-r</span> release https:<span style="color: #000000; font-weight: bold;">//</span>go.googlecode.com<span style="color: #000000; font-weight: bold;">/</span>hg<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #007800;">$GOROOT</span></pre></div></div>

<p>And once it finishes checking out, create the <code>bin</code> directory and compile with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$GOROOT</span><span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$GOROOT</span><span style="color: #000000; font-weight: bold;">/</span>src
.<span style="color: #000000; font-weight: bold;">/</span>all.bash</pre></div></div>

<p>If all went right, you are now ready to start using Go. You may check by typing 8g or 6g (for 386 and amd64 respectively) and seeing if it executes the compiler. I must say that the installation worked flawlessly for me following the instructions in Go's homepage, so up to this point this guide is just an adaptation taking care of Ubuntu's specific parts.</p>
<h3>Keeping Go up to date</h3>
<p>Go's development is quite lively. Roughly 10 minutes past installing, I checked the repository and there were 15 new updates. So it's a good idea to have a recent version of Go installed (specially if you are going to do things as bug reporting).</p>
<p>You can keep your installation updated by executing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$GOROOT</span>
hg pull <span style="color: #660033;">-u</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> src
.<span style="color: #000000; font-weight: bold;">/</span>all.bash</pre></div></div>

<p>Also, if you would want to remove Go from your system, it's as easy as deleting the $GOROOT directory and removing the added lines from your .bashrc file.</p>
<h3>Start!</h3>
<p>OK, now you are ready to start experimenting with Go. You can write the standard Hello World program as:</p>

<div class="wp_syntax"><div class="code"><pre class="go" style="font-family:monospace;">package main
&nbsp;
import format &quot;fmt&quot;
&nbsp;
func main() {
	format.Printf(&quot;Hello World!\n&quot;)
}</pre></div></div>

<p>And compile, link &#038; run with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">8g hello.go
8l <span style="color: #660033;">-o</span> hello hello.8
.<span style="color: #000000; font-weight: bold;">/</span>hello</pre></div></div>

<p>As side note, if you are interested in a system wide installation (instead of per-user, as I just described), change your $GOROOT declaration to somewhere where every user has read permissions (like <code>/opt/golang</code> or <code>/usr/local/golang</code>), and edit /etc/environment instead of your user's .bashrc. Also, you will have to execute most commands with sudo as you will need write permissions under $GOROOT.</p>
]]></content:encoded>
			<wfw:commentRss>http://carinae.net/2009/11/first-steps-with-go-in-ubuntu-karmic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
