GO to study notes a basic article

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

The Go program is made up of packages.

The entrance to the program is the package ' main '

Import package using import statement (similar to C-language include)

When a package is imported, it is invoked with the exported name (the exported name is capitalized)

The function in go declares that the arguments in the function can have no arguments or accept multiple arguments. The type declaration is after the parameter name and the function definition.

The return value of Go can be named after the same as the variable to use.

The VAR statement defines a list of variables that are declared after the variable name. If initialization is using an expression, you can omit the type declaration, and the variable will determine the type based on the initial value.

A variable is assigned a value of zero when it is not explicitly initialized

The ": =" simple assignment statement can be used instead of the keyword "var". Each statement outside the function must start with a keyword, ": =" A concise assignment statement cannot be used outside of a function

The expression T (v) is the type that converts v to T. Unlike the C language: Go in different types of target assignment is required to display the conversion

The definition of a constant uses the keyword "const". Constants cannot be defined using the ": =" syntax.

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.