GO Lang Installation

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

Installation

To build Go 1.x (x≥5), you need to first install Go 1.4 $GOROOT_BOOTSTRAP . The default $GOROOT_BOOTSTRAP is $HOME/go1.4 . We use Go 1.4 as the base version of the boot to compile the toolchain.
Install go1.4 First, then install go1.6.2 or other versions.

Preset go1.4

Download go1.4.linux-amd64.tar.gz or other correspondence package, this is already compiled well, larger, directly there is a bin file available
Unzip the package, modify the directory name go->go1.4
Move to $HOME/ next, there will be a path after the installation is complete /root/go1.4/bin

Install new version

Add the environment variable, ~/.BASHRC, and add the following variable:

export GOROOT=$HOME/goexport PATH=$GOROOT/bin:$PATH

Run environment variables:

source ~/.bashrc

$HOMEPath is /root
Installing the Go tool chain

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

Installing mercurial

sudo apt-get install mercurial

Download go source extract to the $GOROOT directory
I downloaded it from here, and I can get it from other places.

http://www.golangtc.com/download

Compiling go source code

cd$GOROOT/src./all.bash

If the installation is successful, the following information is displayed:

##### ../test##### API checkversionis"go1.6.2"ignoring -next /root/go/api/next.txtALL TESTS PASSED---forinin /root/go/bin

Test

To create a file a.go :

package mainimport(    "fmt")func main(){    fmt.Println("hello world")}

Execute command:

go run a.go

Reference

Http://www.cnblogs.com/ztiandan/archive/2012/12/08/2808295.html
Http://www.cnblogs.com/ztiandan/archive/2012/12/08/2808856.html

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.