This is a creation in Article, where the information may have evolved or changed.
It's been a long time since I've been writing new posts for a variety of reasons (well, actually, lazy)! Recently just learning a new language, so just record your learning results! A few hours after coming back from work every night to learn about Google's development of the go language is a basic understanding of it. It's really a beautiful and chic language.
First go language: Google's November 10, 2009 launch of a new programming language, it can reduce the complexity of the code without loss of application performance. Its main features are: simple and fast security parallel fun open source support generic programming, memory management, array security, compile quickly and so on! And, it is a static, compiler-type language! is a general-purpose language that can be used to develop any software-from common applications to system programming. Although the language is immature, the language features and specifications are changing, but programmers are now using it to develop their work.
In detail, its design objectives are as follows (from Wikipedia and Golang FAQ):
Security: Type safety and memory security. No inheritance, no handling of type dependencies, weakening of type usage, default initialization of variables, simplified design burden.
Support for concurrency and communication. The built-in concurrency mechanism makes multithreaded programming very simple, and the built-in Chan (channel) type simplifies communication between threads.
A complete memory garbage collection mechanism.
High-speed compilation. No header files, makefile and other complex engineering dependencies, making the compilation faster, the project easier to organize.
Advantage:
1. It is a system-level language, statically compiled, and is a C-series language.
2. There are many built-in libraries that are very similar to Python.
3. Syntax is simple enough, the introductory learning cost is very low, for PHP and python to switch over the people.
4. Fast, take simple page, with PHP development concurrency can reach 500 very good, but with go easy to tens of thousands, this is incomparable performance improvement, and with go development efficiency and PHP almost.
5. From Google hand, and a bunch of cattle in the maintenance, based on BSD open source, community active.
6. Its syntax concise, all for the program personnel Services, reduce the program development costs!
Disadvantages:
1. Some libraries are immature, as is the case with processing.
2.cgo under the window System compile very troublesome, take SQLite database driver, in the window under the compilation will encounter a lot of trouble and so on.
The above is some introduction to the Go language, title, I say it is a unique language, mainly its grammatical simplification, compared to traditional languages such as: C type language, it is very brief introduction unique! The whole language feel more easy to learn, of course, learning a new language is actually more difficult, but the difficulty is not from the language itself, but for the whole computer basic knowledge, has been programmed to understand the knowledge of learning!
The homepage is its introduction to the package:
Import "FMT" import "flag"//Can be imported directly ("FMT" "Time" "flag")//can also give the imported wrap individual name import (f "FMT" T " )//can also be used. Omit to call the in-package method directly in the program without having to bring the package name import (. "FMT")//and can be used to indicate that only the init () function in the package import (_ "Github.com/go-sql-driver/mysql") is introduced
The process control statements such as If/for in Go are:
If a > 10 {...} For I, J: = 0, 10; I < J; i++ {...}
They do not require parentheses () in the language between the for,if and other keywords to the opening brace, and the syntactic requirement that the opening brace must be the same line as the preceding statement! (Not a bit strange)
And, of course, the definition of a variable:
The variable var a intvar b string can be defined so var a, b, c int = 1, 2, 3//can also be such var (a int = 1 b string = "")///Not only that, I can also not declare the type , instead of the value to derive the variable's type var a = 2//And within the function, you can define the variable a: = 1c, d, E: = 1, 2, 3
Definition of the function:
Use the Func keyword to define a function, func getName (name string) (Prople string) {prople: = name return prople}//function can also return two values func getData (num i NT) (data, err) {data, err: = num + ten return data, err}
From the above can be seen in the go language of some differences, and grammar concise, in the study, slowly will let you fall in love with it, it is so different, concise, chic!
Of course it's not just these, there are many different features such as type, interface interface, definition of Count constants, arrays, slice slices, map arrays, goroutine, channel channels, etc. These will be in the post of the meaning for everyone to introduce, here is not much to say! Thank you for reading!
This article by the ordinary Childe original release, Welcome to read and reprint!