Ubuntu Go language Environment builds _go language

Source: Internet
Author: User
Tags install go mercurial
1, C language Tools Go tool chain is written in C language, build needs to install the following development tools: GCC, C language standard library, Bison, make, awk and so on. For Ubuntu/debian systems, run the Install command: sudo apt-get install bison ed gawk gcc Libc6-dev make

2. Installation Mercurial
You need to install the Mercurial version management system (you can output HG name detection for installation) before you do the following. Install enter the following command:
sudo easy_install mercurial
For Ubuntu/debian Systems, the Easy_install command can be used
Apt-get Install Python-setuptools Python-dev build-essential
Installation.
If the above command fails, you can also download it from Mercurial Download.
3, get the code
The following command creates a go directory. Switch to the appropriate directory and make sure that no go directory exists at the current location, running the command:
HG Clone-r Release Https://go.googlecode.com/hg/go
It's not usually routed to Google.
So you can click on the open link to download go1.3.3.src.tar.gz
4, add the go1.3.3.src.tar.gz to the Ubuntu under the decompression
root@ubuntu:~# tar-zxf go1.3.3.src.tar.gz 
root@ubuntu:~# ls
1.txt  go  go1.3.3.src.tar.gz  Yankring_history_v2.txt

You'll see one more go file under the current directory.
5. Install Go
CD go/src
./all.bash

Post-compile End information:

All TESTS passed---installed go forlinux/amd64in/home/calvin/go installed commands * * * you In/home/calvin/go/bin To Add/home/calvin/go/binto your PATH.
6. Configure Environment variables
Mkdir/usr/local/go
CP  -RP bin Doc include/lib//usr/local/go/
vi/etc/profile

Plus:
Export path= $PATH:/usr/local/go/bin
export goroot= $HOME/lnk

So you can compile the go file directly under Home/lnk.
7, testing
root@ubuntu:/home/lnk/restgo# vi hello.go
root@ubuntu:/home/lnk/restgo# 
root@ubuntu:/home/lnk/restgo# 
root@ubuntu:/home/lnk/restgo# go run hello.go 
Hello, the world

----------------------------------------------------
Test go, the classic Hello World
Hello.go File Contents:
root@ubuntu:/home/lnk/restgo# Cat Hello.go
Package main


Import "FMT"


func Main () {
fmt. Printf ("Hello, world\n")
}


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.