"Go language Programming" learning note one

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

go语言是一门静态类型的开发语言

Features of the Go language:

    1. Automatic garbage collection
    2. Richer built-in types
    3. function multiple return value
    4. Error handling
    5. Anonymous functions and closures
    6. Types and Interfaces
    7. Concurrent programming
    8. Reflection
    9. Language interactivity

New data types in the Go language

    1. Dictionary type (map)
    2. Array slices (Slice). You can think of an array slice as an array that can grow dynamically.

First GO Program

// go1 project main.gopackage mainimport (    "fmt")func main() {    fmt.Println("Hello, world. 你好,世界! ")}

Print effect

The start of each go source file is a package declaration that represents the packages to which the go code belongs. The package is the most basic distribution unit in the Go language, and is also the embodiment of the dependency relationship in engineering management. To build the go executable, you must create a package with the name main and include a function called main () in the package, which is the starting point for the go executable.
The main () function of the go language cannot have parameters, nor can it define return values.
Import statement for importing packages on which the program depends

Go function

func 函数名(参数列表)(返回值列表) {// 函数体}

Support for multiple return values:
As follows: Supports two return values

funcintfloat64float64, err error) {// 函数体}

One is called result and the other is err. Not all return values must be assigned a value. Return values that are not explicitly assigned when the function returns are set to the default values, such as result is set to 0.0, and err is set to nil.

Go Comment mode

1. Block Comment:

/*块注释*/

2. Line Comment:

//行注释

The Go program does not require the developer to add a semicolon after each statement to indicate the end of the statement

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.