Go case study: Hello World

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

Our first example is to print the classic "Hello World" message, let's look at the code first.

Package Mainimport "FMT" Func Main () {FMT. Println ("Hello World")}

The output is:

$ lsel_01_hello_world.go$ Go build el_01_hello_world.go $ lsel_01_hello_world el_01_hello_world.go$./el_01_hello_ World Hello World

In order go文件 for a package name to be able to be, 编译 可执行文件 main then we import the package that provides the formatted output fmt , the execution entry of the program is the func main() function, inside the function, we use fmt the function provided by the package Println to output "Hello World "string.

In order to run this program, we can use it go run el_01_hello_world.go to run this example, which is to output the running result directly without producing any intermediate files. But sometimes we want to be able to compile the program into a binary file, and we can use it as above go build el_01_hello_world.go to compile the source code into a binary executable. Then we can run the binary executable directly.

Okay, so the first example is over. Very simple.


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.