In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the basic knowledge of Go language introduction". In daily operation, I believe that many people have doubts about the basic knowledge of Go language introduction. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions about "what is the basic knowledge of GE language introduction". Next, please follow the editor to study!
A brief introduction to Go
1. What is go language?
In 2007, Rob Pike, the chief software engineer of Google, who was fed up with C++, gathered two awesome men, Robert Griesemer and Ken Thompson, and decided to create a new language to replace Clover, which is Golang. GO, which appeared in the 21st century, can not replace C++ as desired, but its near-C execution performance, near-analytical language development efficiency and near-perfect compilation speed have become popular all over the world. Especially in cloud projects, most of them use Golang for development, and I have to say that Golang has long been deeply rooted in the hearts of the people. For a new project with no historical burden, Golang may be the right choice.
Rob Pike, known as the father of the GO language, said that whether you agree with the GO language or not depends on whether you agree that less is more or less (Less is more or less is less). Rob Pike sums up the whole design philosophy of the GO language in a very simple way-making it simple and practical.
Many people call GO the C language of the 21st century, because GO not only has the simplicity and performance of C, but also provides a variety of practical features of server development in the 21st century Internet environment, so that developers can easily get what they want at the language level.
2. Golang language features
(1) garbage collection
Memory is automatically reclaimed, and developers are no longer required to manage memory. Developers focus on business implementation, reducing the mental burden. Only new is required to allocate memory, not free.
(2) Natural concurrence of goroute
It is very simple to support concurrency at the language level. Using a go will automatically open a thread to execute the following commands / functions / methods at compile time, instead of calling the thread module to open the thread goroute, lightweight threads, it is possible to create thousands of goroute. Based on CSP (Communicating Sequential Process) model.
(3) multiple return values
The function of Go can have multiple return values
"``
Func main () {
XMagne80 (10page80)
/ / x _: = p_fun (10 ~ (80)) when a function with multiple values is returned, only one value is returned.
Fmt.Println (XBI y)
}
/ / multiple return value function
Func p_fun (an int,b int) (int,int) {/ / function passes two integer arguments and returns two values, both of which are of type int
Sum: = aqb
Avg: = (aqb) / 2
Return sum,avg
}
(4) go's concept of "package"
a. As with python, put code with the same functionality in a directory called a package.
b. Packages can be referenced by other packages.
The c.main package is used to generate executable files, and each program has only one main package.
d. The main purpose of the package is to improve the reusability of the code.
e. Reference to the package
Go uses "package" on the first line to declare its package (the main package is main, or you can customize the package name), "import" introduces other packages, and the path of the system package that comes with go has been set in the "GOROOT" environment variable.
You can use "import" to import directly, while the self-defined package: package needs a relative path when importing import: the third-party package is found in the src directory under the path where the "GOROOT" and "GOPATH" environment variables are located.
(5) go file coding specification
Use gofmt to make the code in the go file more standardized (indentation, etc.), and use gofmt-w to modify the original go file to be more standardized.
At this point, the study of "what are the basic knowledge of Go language introduction" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.