Go Language Learning Notes (i) Basics of the basics

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

Before graduation, every month was a list of programming languages to relish. Pay attention to the seats in the front row, but will also pay attention to the previous not heard of the various languages. Now work, just occasionally will think of to see two eyes, also will not for the language ranking situation too much. Recently, the company suddenly became a go language for the development of the language group, I usually may work too leisurely, in the group also can not play a big role, then was drawn over dine. Now I know, the original bug changed the day is how beautiful. Although I do not like the "front-end development" of the words, but how to say a little bit of foundation, usually encountered problems can quickly find a breakthrough. Now, is a variety of not heard, all kinds of learning ah. That's no way of doing it. Hope that through this period of learning to change my procrastination does not work hard bad habits. The eldest brother said, remember more notes, is still very good. (hehe, Sheng see more, I can't remember the exact words, anyway is this meaning)

Talk less, start to record today's study progress. Control statement, the basis of the array is read, a lot of small programs have been implemented a bit. In depth, there are some special situations that need to be remembered that have not been carefully looked at. Anyway, I'm going to go through these ebooks a few more times.

This is the case with the approximate program structure, which is to have the package and import the packages. The most awkward thing is that the brackets are not bracketed, there are rules for the various lines of change. Because I used to use Java before, it is possible to add the semicolon. The go language can be at the end of the statement without a semicolon, because it will automatically add a semicolon, there is a problem is more troublesome, if not in accordance with the specified format, go compiler has no way to compile successfully, there will be a syntax error. Like in Java, {} can be followed by a judgment condition, or another line, but in go, you must follow the criteria behind the judgment. At the beginning of the habit ah, always mistaken.

Although there are uncomfortable places, there is also a place where people can be enlightened. Although I was first in touch with the go language, I was shocked by switch. It's so awesome, it's so nice, first on the code.

In the Java language, the expression in switch must be a constant or an integer, and go is very flexible. The switch can have an expression, but it can also be judged directly into the case, as there is no expression in the previous example. A case can include a determination of various conditions. Well, that's the advantage of other languages I've never seen before.

Go in the variable declaration is very characteristic, for example, var a int this statement declares an integer variable A, a bit like the MySQL database building table of the wording, see can adapt to it. The result of this declaration is somewhat similar to that of Java, although it does not indicate what value it is, but it assigns the default value of this type to it by default. You can also declare this: temp: = 151 statements complete the Declaration and initialization of the variable. Without explicitly naming the data type, it is convenient to specify the type of the variable according to the type of the subsequent value.

There are also such assignment forms: A, B: =10,16 equivalent to a=10,b=16, really convenient.

Also, like some of the more mainstream programming languages, the return value of a function is at most one, and the return value in go can be any, about the function is still learning ...

Today, three or four hours to learn these, but also the meeting, open a backache, are not how to understand. Really feel, and those technical Daniel's gap is far away, so, must study hard, early to get rid of the rookie's hat.

Go is still going on ...

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.