Introduction to the development of Go language programming

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

Introduction to the development of Go language programming: Go language is a new system-level language developed by Google, Project home: http://golang.org/

1. Install the Go Language environment

The go language is used primarily for Linux environments and provides source code installation. For a complete description of the relationship installation, please refer to
Official website: http://golang.org/doc/install.html.

The documentation here is primarily for users of Linux systems. Go uses mercurial management code, so it needs to be installed now
Mercurial tools. In addition, the go compiler relies on the following tools: Bison/gcc/libc6-dev/ed/gawk
and make.

Create an empty directory first, assuming that the $HOME/go, you can get the source code with the following command:

Code: Select All
$ HG clone-r release https://go.googlecode.com/hg/$HOME/go
Then configure the environment variables:

code: Select all
export goroot= $HOME/go
export goarch=386
export goos=linux
export gobin= $HOME/bin
gobin corresponds to the directory that the Go compiler tool places, to ensure that the corresponding directory exists. Then add the Gobin directory to path:

Code: Select All
Export path= $GOBIN: $PATH
Use the following command to see if the environment variable is already set:

Code: Select All
$ env | grep ' ^go '
If everything is ready, you can start compiling the go:

Code: Select All
$ cd $GOROOT/SRC
$./all.bash
If the compilation succeeds, you can see the following end information:
Code: Select All
-CD. /test
N known bugs; 0 Unexpected bugs
After the compilation succeeds, you can try the Godoc command if it is available.

2. Hello, World

Let's take a look at what the classic "Hello, World" program looks like in go:

Code: Select All
Package Main

Func Main () {
Print ("Hello, World \ n")
}
Save to the Hello.go file and compile with the following command:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

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.