Golang New Sail! (Compile and install go)

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

Don't talk nonsense, go straight on ~

Install GO1.8 under Linux

1, download the version of Go

Domestic address Source: https://dl.gocn.io/

Choose the source code here to install, in the installation of Go is required gcc, so your Linux system needs to install GCC first. If you install the 1.8 version directly, you will be prompted with the word >=1.4. This is because when you install a high version, you need to provide a basic version, which is like "chicken or Egg first" situation. So we have to provide a "hen" first. The choice here is 1.4.3 as the base version, because this version of Go is still pure C, so there is no need to rely on it.

  

2. Compile and install

Unpack the package under your Linux system.

  

Here, we first define the directory specification, the home directory to create a new/local/directory, the download of 1.4 and 1.8 two versions into which to unzip the renaming.

    • Compile and install version 1.4.3, run the make.bash file under src

  

Installation Complete

  

You can see the version 1.4.3

  

    • Continue compiling version 1.8

The procedure is the same, run the Make.bash file under the 1.8 version of SRC

However, you will still receive a prompt after running:

    

Note that the $GOROOT _bootstrap here will require you to set the environment variables for the installation directory, and then continue to execute

  Export goroot_bootstrap= $HOME/local/go1.4

  

Installation is complete!

  

  

3. Setting Environment variables

Not fully finished after compiling go1.8, three environment variables needed to be set

So. We need to change the directory name before go1.8.

    

Modify our BASHRC file to write environment variables

  Vim ~/.BASHRC

Export goroot= $HOME/local/go
Export Gopath= $HOME/go
Export path= $GOROOT/bin: $GOPATH/bin: $PATH

  

Save after exit effective configuration

    SOURCE ~/.BASHRC

perform go env to see configuration information

  

4. Run Hello Golang

Edit File Hello.go

  

Save exit, run go run hello.go See effect

  

At this point, if the operation is successful, the go environment has been built successfully ~ ~ ~

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.