
The installation guide for Go is pretty straightforward. Still, I am going to rewrite that specifically for 32-bit Ubuntu (9.10) system.
First you need the set the environment variables. Open the .bashrc file from your home directory. Add the following lines at the end.
export GOROOT=$HOME/go export GOOS=linux export GOARCH=386

Next, install mercurial. To do that use the command
$ sudo apt-get install mercurialYou are now ready to download the source code for Go.
$ hg clone -r release https://go.googlecode.com/hg/ $GOROOTYou need to compile the source code. For that you will require gcc, the standard C libraries, the parser generator Bison, make and the text editor ed installed. Run the following command. It will install these things if they are not already installed.
$ sudo apt-get install bison gcc libc6-dev ed makeCreate the directory
bin in your home folder. You can use the command:$ mkdir $HOME/bin

Make sure the $HOME/bin directory is in your path. You may have to just log off and re-login after you create the bin directory. The bin directory in your home will be automatically added to $PATH.
To check the contents of PATH variable, use the command
echo $PATH

Now, start the compilation
$ cd $GOROOT/src $ ./all.bashThat's it. If everything goes well, it will finish by printing
--- cd ../test N known bugs; 0 unexpected bugsN will vary from release to release.
Now lets write a simple program.
package main
import "fmt"
func main() {
fmt.Printf("Hello, World\n")
}
Save the program in a file hello.go.Compile, link and run the program.
To compile:
$ 8g hello.goTo link:
$ 8l hello.8And to Run:
$ ./8.outThat should print the phrase "Hello, World".
To learn more about the Go Programming language read the tutorial here http://golang.org/doc/go_tutorial.html
0 comments:
Post a Comment