Linux system Go development environment building

Source: Internet
Author: User

The Go language, developed by Google scientists and open source, is known as the "C language of the 21st century", and its main goal is to combine the security and efficiency of static language with the easy development of dynamic language to achieve a perfect balance, thus making programming more enjoyable rather than painful in difficult choices.

The project team decided to develop a front-end flood-fighting server in the go language, with a recent project dealing with the instant high concurrency request, taking into account the native support concurrency feature of the Go language and the development of multiple projects in the go language after the new year. 工欲善其事, its prerequisite, below the Linux system under the development of the go environment to build.

There is a lot of information on the go environment, which is installed from the installation mercurial , then download the Go language source. But because of the well-known reasons, there is no stable access to Google's servers in mainland China, so the above method is not feasible in many cases, unless a proxy is used. Here's a very simple and very effective way to build a go development environment.

注意: To install the Go development environment under Linux, please use the root user .

# # #下载Go文件压缩包
To Golang Chinese community to download the source of the Go language, the Linux command line can execute the following command:

1 wget http://www.golangtc.com/static/go/go1.8.3.linux-amd64.tar.gz

Unzip the file after downloading:

1 TAR-ZXVF go1.8.3.linux-amd64.tar.gz

To get a go directory, execute the following command to move to the /usr/local/ directory:

1 MV go//usr/local/

# # #Go配置环境变量
To open a file using the Vim editor /etc/profile :

1 Vim/etc/profile

At the bottom, add the following to configure the GO locale variable:

12345 #set Go Environment goroot=/usr/local/Go gobin= $GOROOT/bin path= $PATH: $GOBIN/ export Goroot GOBIN PATH

The environment variable configuration in the Code>/etc/profile file ensures that the environment variable is available to every user on the machine. Execute the following command to make the environment variable effective:

1 Source/etc/profile

Verify that the environment variable is in effect and if the console outputs the path configured above, the configuration succeeds:

1 Echo $GOROOT

To switch to the user who deploys the Go service, you can, of course, continue to be the root user, configuring GOPATH environment variables:

1 Vim ~/.profile

Edit the following in the bottom section:

1 Export Gopath=/data/go

Then run the following command to make the environment variable effective:

1 SOURCE ~/.profile

Create a file in the /data/go directory main.go and write the following:

1234567 Package Main Import "FMT" func main() { fmt. Println ("Hello, World! ")}

Run after Save:

12 Go Run/data/go/main.gohello, the world!

The successful printing of the message means that the installation is successful!!

Linux system Go development environment building

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.