{"id":275,"date":"2009-11-24T23:21:06","date_gmt":"2009-11-24T22:21:06","guid":{"rendered":"http:\/\/www.gennard.net\/blog\/?p=275"},"modified":"2009-11-24T23:21:06","modified_gmt":"2009-11-24T22:21:06","slug":"go-baby-go","status":"publish","type":"post","link":"http:\/\/www.gennard.net\/blog\/2009\/11\/go-baby-go\/","title":{"rendered":"GO Baby GO.."},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/cdn.mashable.com\/wp-content\/uploads\/2009\/11\/go-logo-black.png\"><\/p>\n<p>As someone who works with &#8216;C&#8217;, MSIL and Java bytecode to write system level software for our compilers and runtime, I was nicely surprised to see that someone has produced a new language aim at &#8216;System Level Programming&#8217;.  Let me introduce you to &#8216;GO&#8217; Googles new language and of course it is open source.<\/p>\n<p>So why has google created the language?  Well it is better to let Google themselves say why? (taken from their FAQ..)<\/p>\n<blockquote>\n<p>No major systems language has emerged in over a decade, but over that time the computing landscape has changed tremendously. There are several trends:<\/p>\n<li>Computers are enormously quicker but software development is not faster.<\/li>\n<li>Dependency management is a big part of software development today but the \u201cheader files\u201d of languages in the C tradition are antithetical to clean dependency analysis\u2014and fast compilation.<\/li>\n<li>There is a growing rebellion against cumbersome type systems like those of Java and C++, pushing people towards dynamically typed languages such as Python and JavaScript.<\/li>\n<li>Some fundamental concepts such as garbage collection and parallel computation are not well supported by popular systems languages.<\/li>\n<li>The emergence of multicore computers has generated worry and confusion.<\/li>\n<\/blockquote>\n<p>Enough quotes.. I hear you say.. so what next if you want read more.. drive over to <a href=\"http:\/\/golang.org\/\">http:\/\/golang.org\/<\/a>.. now lets get practical and it up and running, as it is open-source and very young its a d.i.y. job&#8230; still it looks easy enough&#8230;<\/p>\n<p>They says its simple build&#8230; so lets put it to the test.. let my diary begin&#8230;<\/p>\n<p>Firstly&#8230; I&#8217;ll be up front and say these instructions are for the Mac OSX and tested on my little MacBook running 10.6 with xcode pre-installed.. <\/p>\n<p>1) First download Mercurial source control:<\/p>\n<p> <a href=\"http:\/\/mercurial.selenic.com\/downloads\/\">http:\/\/mercurial.selenic.com\/downloads\/<\/a><\/p>\n<p>2) Add the following to $HOME\/.bash_profile using vim<\/p>\n<p><code lang=\"text\" width=\"800\" lines=\"-1\" nowrap=\"0\"><br \/>\nexport PATH=$HOME\/bin:$PATH<br \/>\nexport GOROOT=$HOME\/go<br \/>\nexport GOARCH=amd64<br \/>\nexport GOOS=darwin<br \/>\n<\/code><\/p>\n<p>Tip: if you don&#8217;t have a directory called bin, do a quick &#8220;mkdir $HOME\/bin&#8221;<\/p>\n<p>3) Startup a new terminal session and check to see if the environment have been set with:<\/p>\n<p><code lang=\"text\" width=\"800\" lines=\"-1\" nowrap=\"0\"><br \/>\nenv | grep \"^GO\"<br \/>\n<\/code><\/p>\n<p>If all goes well you should see:<\/p>\n<p><code lang=\"text\" width=\"800\" lines=\"-1\" nowrap=\"0\"><br \/>\nGOARCH=amd64<br \/>\nGOROOT=\/Users\/spg\/go<br \/>\nGOOS=darwin<br \/>\n<\/code><\/p>\n<p>4) Okay, lets download the latest source code for Go!<\/p>\n<p><code lang=\"text\"><br \/>\nhg clone -r release https:\/\/go.googlecode.com\/hg\/ $GOROOT<br \/>\n<\/code><\/p>\n<p>The &#8216;hg&#8217; command gets the source code and hopefully your screen should be something like!<\/p>\n<p><code lang=\"text\" width=\"800\" lines=\"-1\" nowrap=\"0\"><br \/>\nrequesting all changes<br \/>\nadding changesets<br \/>\nadding manifests<br \/>\nadding file changes<br \/>\nadded 4109 changesets with 17125 changes to 2968 files<br \/>\nupdating to branch default<br \/>\n1676 files updated, 0 files merged, 0 files removed, 0 files unresolved<br \/>\n<\/code><\/p>\n<p>5) Now lets build it&#8230;<\/p>\n<p><code lang=\"text\" width=\"800\" lines=\"-1\" nowrap=\"0\"><br \/>\ncd $GOROOT\/src<br \/>\n.\/all.bash<br \/>\n<\/code><\/p>\n<p><code lang=\"text\" width=\"800\" lines=\"-1\" nowrap=\"0\"><br \/>\nwow.... A lot goes bye.... and then finally... it ends with......<br \/>\nk-nucleotide<br \/>\nmandelbrot<br \/>\nmeteor-contest<br \/>\npidigits<br \/>\nthreadring<br \/>\nchameneosredux<\/p>\n<p>--- cd ..\/test<br \/>\n1 known bugs; 0 unexpected bugs<br \/>\n<\/code><\/p>\n<p>Wow&#8230; I appear to have something installed&#8230; it took me&#8230;  less than fifteen minutes..<\/p>\n<p><p>So lets try some of the samples out&#8230;<\/p>\n<p><code lang=\"text\" width=\"800\" lines=\"-1\" nowrap=\"0\"><br \/>\nstephen-gennards-macbook:src spg$ cat hello.go<br \/>\npackage main<\/p>\n<p>import \"fmt\"<\/p>\n<p>func main() {<br \/>\nfmt.Printf(\"hello, worldn\")<br \/>\n}<br \/>\nstephen-gennards-macbook:src spg$ 6g hello.go<br \/>\nstephen-gennards-macbook:src spg$ 6l hello.6<br \/>\nstephen-gennards-macbook:src spg$ .\/6.out<br \/>\nhello, world<br \/>\n<\/code><\/p>\n<p>Ohhh&#8230; my that was too easy&#8230; its time to leave the blog and start playing&#8230;<\/p>\n<p>What next&#8230; guess its time to watch a video about Go!<\/p>\n<hr>\n<p><object width=\"560\" height=\"340\"><param name=\"movie\" value=\"http:\/\/www.youtube.com\/v\/rKnDgT73v8s&#038;hl=en_US&#038;fs=1&#038;\"><\/param><param name=\"allowFullScreen\" value=\"true\"><\/param><param name=\"allowscriptaccess\" value=\"always\"><\/param><embed src=\"http:\/\/www.youtube.com\/v\/rKnDgT73v8s&#038;hl=en_US&#038;fs=1&#038;\" type=\"application\/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"560\" height=\"340\"><\/embed><\/object><\/p>\n<p>[ad#Google Adsense-3] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>As someone who works with &#8216;C&#8217;, MSIL and Java bytecode to write system level software for our compilers and runtime, I was nicely surprised to see that someone has produced a new language aim at &#8216;System Level Programming&#8217;. Let me &hellip; <a href=\"http:\/\/www.gennard.net\/blog\/2009\/11\/go-baby-go\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45,10],"tags":[237,212,152,155],"_links":{"self":[{"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/posts\/275"}],"collection":[{"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/comments?post=275"}],"version-history":[{"count":0,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/posts\/275\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/media?parent=275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/categories?post=275"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/tags?post=275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}