Support Forums

Full Version: Installing Google "Go" on fedora
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Note: I posted this on hackforums a while ago. Thought it would be useful here.


If you haven't heard the news, google has released it's own programming language! It's website is here: http://golang.org

It's a very new language, but seeing the kind of influence google has on the open source world (oh yeah, the language is open source!) and on the general world of computing it's probably a good idea that you at least have the "Go" compiler installed.

First off what you want to do when installing go is check out their page on installation, here: http://golang.org/doc/install.html.

Now, that's a very complete guide. Much better than you can expect from me, tbh. However, I found it wasn't specific enough on some points, and I found myself asking lots of questions in #go-nuts in freenode. (it's their irc channel, you should check it out!)

Back to the topic at hand...The first thing that the guide says to do is to set the environment variables. ( http://lmgtfy.com/?q=linux+environment+variables )

The first variable you want to set is $GOROOT, which will be the bottom directory for your installation of go. Now, as you probably know, the linux filesystem has a /home folder, and then different folders in that folder for each user. This means that you, yes you, have a /home/Your_Account_Name folder all to yourself. If you want to see what that is, you simply have to ender the following command in the terminal:

Code:
$ echo $HOME
/home/Your_Account_Name

Now, your root path is supposed to be a file within your HOME path, so to set it, you would do...

Code:
$ export GOROOT=$HOME/go
$

Beautiful. Next you want to set the GOOS variable and the GOARCH variable, which represent the target operating system, and the target architecture, respectfully. This can be done with the following commands.

Code:
$ export GOOS=linux #the title of this thread said fedora, what'd you expect?
$

Code:
$ export GOARCH=386 #might not be your architecture.
$

from here, we need one more environment variable with is GOBIN. (note: this is optional, but since we're leet, we're gonna make it anyway)

Code:
$ export GOBIN=$HOME/bin
$

Now, those are going to stay there - for one session only. As soon as you hit 'x' on your terminal window, they will go away. Gone, forever. That's why you have to put them in your ~/.bashrc file. This can simply be done by using the following command:
Code:
$ nano ~/.bashrc
and making the file have the four commands we just talked about. In essence it should look something like this:
Quote:# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions
export GOBIN=/home/FarOut/bin
export GOARCH=386
export GOOS=linux
export GOROOT=/home/FarOut/go

There you go. You've got your environment variables down, and you're ready to install.

First thing's first: install mercury.

Code:
$ sudo yum install mercury

Once that's done, you may enter the following command to fetch the repository from google code:
Code:
$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT

ALMOST THERE!

from here, you must make sure $GOBIN is in your $PATH environment variable.

to check if it is, you would enter the following commands:
Code:
$ echo $GOBIN
/home/name/bin
$ echo $PATH
/lots/of/directories:/more/directories:/you/only/care/about/one

What you want to check for, is to see if what was printed when you entered the echo $GOBIN command, was also in the $PATH variable. if it wasn't, you would add it with the following command:

Code:
$ export PATH=$PATH:$GOBIN
$

Beautiful. You're at the easy part, now.
All you have to do is enter the following command to make sure you have the needed tools to compile it:
Code:
$ sudo yum install bison gcc libc6-dev ed

Once that's done, enter the following commands....
Code:
$ cd $GOROOT/src
$ ./all.bash

AND YOU'RE DONE!
Congratulations, you've successfully installed "Go".

*note, take a look at http://golang.org/doc/install.html#tmp_71 for how to use the compiler that you just downloaded.
*note, crap was written in a hurry, let me know of any errors.