Go language Learning

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

1, go of the generation

The go language is the second language developed by Google, and Google engineers feel that using the development language of the past is inefficient and painful in software development, so they have developed this language

The go language is designed specifically for multi-processor system application programming, performance can be comparable to C + +, development efficiency and high, making multi-processor system programming easier and faster. The go language optimizes the use of the Go language for multi-core processor software development. It has the advantages of fast compiling, high efficiency and good performance.


2. Introduction to go language learning

When learning the go language, we can use the IntelliJ Idea tool to program with the Go language, which installs the plugin to highlight the grammar of the Go language.

In the process of learning go language, the go language gives me the first feeling is: introduction, programming feeling is very cool, in my opinion, a programming language first it is a language, language is the pursuit of simplicity, as long as learning a language just can say a problem, the more concise language, programming language is also the same, As long as the function can be achieved, simple and beautiful, go language and other languages I used, such as C/c++,java,python, go language in the concise aspect is not comparable to other languages, the following examples to prove:

1, the Declaration of variables:

int a=1; (Java)

A: = 1 (GO)

A,b,c: = 1,2.0, "KKK"

2. If related

Python:

i = SOMEF ()

If I > 10:

Print ("CKVDKJG")

It's simple, but the go language can be simpler, as follows:

If I: = SOMEF (); i>10{

Print ("CKVDKJG")

}

3, a for to take care of various loops

For i:=0;i<10;i++{

}

For a<b{

}

for{

}

And a for can traverse various list

For I,str:=range {"A": 0, "B": 1, "C": 2, "D": 3}{

}

4, a function can return several different types of values

5, interface no longer to achieve

Type Animal interface{

Cry ()

}

If we define a function as follows:

Func Somgfunc (Animal a) {

A.cry ()

}

When we define the class or interface, we do not need to implement the interface animal, as long as there is a cry () method in the class or interface, it is considered to have implemented animal

It can be used as a parameter to the SOMGFUNC function

5, multithreading more simple

Multi-threaded as long as a go keyword can be implemented

Go Funca (a);

Go Funca (c);

Two threads executed


In short, the go language is very good in terms of brevity, there are some other excellent idea, please do your own research

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.