Ubuntu Install Go language Run environment _golang

Source: Internet
Author: User
Tags install go mercurial version control system

On the Ubuntu forum, I saw a post that grabbed the image data in the Web page, so I tried it with the go language. So let's install a running environment first. The following installation methods are installed successfully on 32-bit and 64-bit ubuntu12.04, and all commands, programs I have actually run, if there is a problem, please leave a message to me.

1. Installation Mercurial

Mercurial is a version control system that will use this tool to download the Go language source. In Ubuntu under the Apt-get installed on the OK, very convenient.

Copy Code code as follows:

sudo apt-get install mercurial

2, download the Go language source

This step creates a new Go folder at the command line's current directory and downloads the code file to the went folder, so make sure there is no Go folder under the current directory. For example, I am operating directly in the/home directory.

Copy Code code as follows:

HG Clone-u Release Https://code.google.com/p/go

3. Start Installation

Copy Code code as follows:

CD GO/SRC
./all.bash

This process takes some time, one-click installation, very powerful. When installed, you will be prompted with information similar to the following.

Copy Code code as follows:

Installed go to linux/386 in/home/go
Installed Commands In/home/go/bin
You are need to Add/home/go/bin to your PATH.

Probably say to go to the bin directory set to $path, this variable is to run the command search path, temporarily do not set it does not matter, you can use the full path to deal with. Since I previously chose the/home directory, the Go Bin directory is/home/go/bin after the installation is complete

4, international practice, the first program Hello world!

Copy Code code as follows:

Package Main
Import "FMT"
Func Main () {
Fmt. Printf ("Hello, world\n")
}

Save as a hello.go file, and then execute

Copy Code code as follows:

/home/go/bin/go Run Hello.go

See Output Hello World Description The environment was installed successfully.

The above mentioned is the entire content of this article, I hope you can enjoy.

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.