Google Go installation experience

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

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

Refer to the official Google documents, and combined with their own experience, is half translated, the general original, which has many do not understand the place, please master pointing

1,     Set environment variables
$GOROOT     :go root directory, generally set to $home/go, or to a different directory
$GOOS          : Target OS currently his options are Linux, Darwin (note: Mac OS X 10.5 or 10.6) and NaCl (note: Native Client, an incomplete Port)
$GOARCH     : Target compilation schema, his options are AMD64 (64-bit x86 or AMD64), 386 (32-bit x86 or amd32), and arm (32-bit ARM platform)
$GOBIN ( Optional): Where binary code is stored, if you specify $gobin, then you must ensure that he is under $path, default, $GOBIN value is $home/bin
Note: $GOOS and $goarch are the target environments in which the code runs, not the environment you are running now. The
can set these variables in the. bashrc file,
For example:
Export goroot= $HOME/go
Export goarch=amd64
Export Goos=linux
Personal experience: You can see the environment variables through the echo $GOROOT, etc., I add the above content in. BASHRC, the echo out of the result is still empty, do not know what is going on, please expert guidance, their own manual command line these three environment variables added, and add a
Export $GOBIN = $GOROOT/bin
Export $PATH = $PATH: $GOBIN
to set $gobin.


2, download
If there is no HG command
$ sudo easy_install Mercurial
Personal experience: I use Fedora 11, so use Yum to install mercurial
The HG command appears to be used for remote login download
$ HG clone-r release https://go.googlecode.com/hg/$GOROOT
Download the file to the $goroot directory
And then
sudo apt-get install bison gcc Libc6-dev ed make
This is the Ubuntu command, because go is given to GCC, so the library to install C
Personal experience:
Under Fedora, yum install Bison gcc Libc6-dev ed make
But did not find the package about Libc6-dev;


3, installation
CD $GOROOT/SRC
./all.bash
If the All.bash runs successfully, it will output
---CD. /test
N known bugs; 0 Unexpected Bugs (n is a number)
Personal experience: Installing to the last two requires network authentication, but it always fails, but does not affect the functionality


4, test
Write a program Hello.go
Package Main

Import "FMT"

Func Main () {
Fmt. Printf ("Hello, world/n")
}
If your $goarch variable is AMD64, the command you use has 6G,6L,6C,6A
If it's 386, then there's 8g,8l,8c,8a.
If it's arm, then there's 5g,5l,5c,5a.
Personal experience: I use 386
Compile:
8g Hello.go
Connection:
8l hello.8
Run:
./8.out
HelloWorld

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.