The structure of the Go language in Lesson two

Source: Internet
Author: User

1 Go language structure

" FMT " Func Main () {   /**/   FMT. Println ("Hello, world! " )}

The basic components of the Go language are the following sections:

    • Package declaration: Defines the package name, the first line of the non-comment in the source file must indicate which package the file belongs to, and packagesmain represents a program that can be executed independently , and each Go application has a a package named Main.
    • Introduction Package: The FMT package implements the format IO (input/output) function.
    • Function: The main function is what each executable program must contain , generally the first function executed after startup (if there is an init () function, the function is executed first ).
    • Variables: When identifiers (including constants, variables, types, function names, structure fields, and so on) start with an uppercase letter , such as: Group1, then an object with this form of identifier can be used by the code of the external package (the client program needs to import the package first), This is known as an export (like public in an object-oriented language); identifiers that start with lowercase letters are invisible to the outside of the package, but they are visible and available within the entire package (like protected in object-oriented languages) )
    • Statements & Expressions:
    • Note: single-line comment//, multiline comment/**/

The structure of the Go language in Lesson two

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.