Conquer go start

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

The previous topic shows that the development environment of the go language under Ubuntu has been set up and we are going to conquer go, and to first understand the features of the go language, let's start with the simplest test "Hello world!" Test the code.

The implementation code in the Go language is very concise. The most test code is written below.

 PackageMainImport "FMT"//import package, including print functionfuncMain () {FMT. Print ("Hello world!")///End Here can also be added '; '}tsong@tsong:~/exc$GoBuild Gotest.Go#编译 tsong@tsong:~/exc$./gotest #运行hello world!GoThe data type and use of the language inGoThere are many types of data built into the language that can be easily used by us, butGoThe definition and initialization of data types in, and C language is a bit different. Use keywords for life variablesvarFor example:varScorefloat64;varAgeint=Ten;//Declaration and initializationvarNamestring="Lizi"Price: =20.9;//System Automatic identification data typevarNumberint; number = -;var(Aint= -; Bint=Ten; ) inGoYou can also give names to literal constants in languages such as:ConstNamestring="China";//literal constant takes the name of the const keyword  
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.