Go language compiler Installation

Source: Internet
Author: User
Tags mercurial
This is a creation in Article, where the information may have evolved or changed.

Near home days, in the company is relatively idle, so find Google's new Go language research and research, but also see the latest programming language rankings, unexpectedly rose to 13, a bit aroused my interest, less gossip.

Reference article: http://golang.org/doc/install.html

Introduction to go language is not here wordy, there will be a lot of, I just record my installation process

1. Environment variable Settings

root directory of Goroot:go languages

Goos and Goarch: the name of the operating system and the name of the compiled schema, some of the following combinations

$GOOS $GOARCH

Darwin 386

Darwin AMD64

FreeBSD 386

FreeBSD AMD64

Linux 386

Linux AMD64

Linux Arm

NAC1 386

Because my operating system is ubuntu9.04, I set the environment variables as follows:

Export goroot= $HOME/workspace/myproject/go
Export goarch=386
Export Goos=linux

2. Pre-Installation Preparation work

Before installing the Go compiler, you need your system to have mercurial, the installation command is as follows

$sudo Easy_install Mercurial

If you're like me your system is also Ubuntu, you'll need sudo apt-get install python-setuptools Python-dev

The next step is to get the resources and continue to follow the instructions to enter a simple command (ensure that goroot does not exist or there are no files in it):

$HG clone-r release https://go.googlecode.com/hg/$GOROOT

3. Install the Go compiler

The go compiler is written in C, so there must be GCC, standard C library, and Bison,make,awk and text editor ed to start the installation. If not, you need to execute the following command

$ sudo apt-get install bison gcc libc6-dev ed gawk make

          start compiling

                $ cd $GOROOT/src

                $./all.bash

           If there are no errors, you will get the following result:

                ---CD. /test
0 known Bugs; 0 Unexpected bugs

          4. Test

            has now installed a compilation environment, the immediate need to do is to test our environment can work properly.

            in the test directory to find an example, we take the most familiar Hello world to do the test, code I do not paste, do the following

                 $8g helloworld.go

                 $8g Helloworld.8

                 $./8.out

Hello, world

The first command compiles, 8g refers to the 386 structure, if it is AMD64 or arm is 6 and 5, compile will generate Helloworld.8, here 8 is related to the compilation schema

The second command is connected, the same as L means link, the generated Helloworld.8 is connected to generate 8.out

And then it's done, not too much explaining.

           5. Update compiler

              Update Recent changes, Bugfix can use the following set of commands:

$ cd $GOROOT/SRC

$ HG Pull

$ HG Update release

                        $./all.bash

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.