The Go language Hello World

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

See a piece of news, inexplicable want to try to be some people praise the go language ...

1. Development environment Construction

"Of course you can install the compiled binary package directly, and Ubuntu's fool-style installation is very strong, here is the compilation steps in Ubuntu"

(1) Installing the mercurial tool, in order to obtain the HG command;

(2) Setting environment variable Goroot

Export Goroot=~/go

Of course, you need to create a new go directory for storing the source directory ...

(3) Get the source code of Go

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

The internet is not good, it took a few minutes to get the code down ...

(4) This can finally compile the source code ...

CD $GOROOT/SRC

./all.bash

Ubuntu in the virtual machine is compiled slowly and slowly ..., wait for it ...

You can see the output after the compilation is complete:

All TESTS PASSED

---
Installed Go for linux/386 In/home/xiaohuan/go
Installed Commands In/home/xiaohuan/go/bin
You need to Add/home/xiaohuan/go/bin to your PATH.

(5) Need to continue setting environment variables

Export path= $GOROOT/bin: $PATH

2. Start writing Hello World

(1) Writing source code

Package Mainimport "FMT" Func Main () {    fmt. Printf ("Hello go!\n")}
(2) compiling the source code

Go Build Helloworld.go

(3) execution, you can see the results

./helloworld

You can see the output: Hello go!

3. Go language

"Good for a short copy"

Go aims to provide the efficiency of astatically typed compiled language with the ease of programming of a dynamiclanguage . [9] Other goals include:

Safety:type-safe and Memory-safe.

Good support for concurrency and communication.

Efficient, Latency-free garbage collection.

High-speed compilation.

A lot of features, later to play ...






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.