The setup and HelloWorld of Go language environment under Ubuntu

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

1. Create the source directory of the Go language and the target directory of the executing program

mkdir ~/go

mkdir ~/gobin

2. Add the environment variables required for the Go language

Export goroot= $HOME/go

Export goarch=386
Export Goos=linux
Export gobin= $HOME/gobin

Export path= $PATH: $GOBIN

Exit the shell and log back in to re-import the environment variable

3. Install the required toolkit for compiling

Apt-get Install Python-setuptools Python-dev

sudo apt-get install mercurial

sudo apt-get install bison gcc Libc6-dev ed

4. Get the Go Language source package

HG Clone–r release https://go.googlecode.com/hg/$GOROOT

5. Compiling the Go Language pack

CD $GOROOT/SRC

./all.bash

6. HelloWorld

Filename:HelloWorld.go

Package Main

Import "FMT"

Func Main () {

Fmt. Printf ("Hello, GO language.../n")

}

6.1 Compilation: 8g Helloworld.go

6.2 Link: 8l Helloworld.8

6.3 Execution:./8.out

Ok

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.