Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Go Languages Reviews     - Haproxy multi-domain certificate HTTPS (Server)

- Analysis of memory mapping process in Linux x86-32 mode (Linux)

- Use Ansible installation NGINX and NGINX Plus (Server)

- Ubuntu installed racing game Speed Dreams 2.1 (Linux)

- Nginx server security configuration (Server)

- RHEL / CentOS / Fedora Install Nagios 4.0.1 (Linux)

- The new features of MySQL 5.7 Generated Column (index function) (Database)

- Installation Yarock 1.1.4 Music Player in Ubuntu (Linux)

- Online booking shocking information leakage risk, you dare book the tickets online? (Linux)

- Linux create and delete user step (Linux)

- Linux kernel network subsystem analysis (Programming)

- Thinking in Java study notes - initialization and cleanup (Programming)

- Ubuntu rights management common commands (Linux)

- To install and deploy Java applications under CentOS 6.5 (Linux)

- Linux operating system security can not be ignored (Linux)

- Installation JDK1.7 under Ubuntu14.04 64-bit (Linux)

- MySQL flip-flop (Database)

- MariaDB database storage path modify configuration issues (Database)

- Oracle 11g new features of the collection of multi-column statistics (Database)

- xargs Detailed description (Linux)

 
         
  Go Languages Reviews
     
  Add Date : 2018-11-21      
         
       
         
  13 In the first half of contact Golang, very fond of Golang. It is 2015, a few days away from the Spring Festival, from the beginning to learn a year and a half now, the back and forth with Golang also write some code, including your spare time, there are products in the project. The idea has been to write a summary of the relevant Golang or feelings, I decided to summarize it in years. Under state: I just Golang preference, not a brain residual powder has no intention to provoke what the language dispute.

Characteristic small and simple grammar. GO is advocating minimalist, advocate less is more. This is in particular to highlight its Spec, an afternoon can definitely read. Characteristics GO little, a lot of users are feedback GO, GO keyword can remember at least in the brain. While its syntax is very simple and clear semantics.

Ease of deployment. GO is a strongly typed static language, code can be compiled to native machine instructions. It RUNTIME is at compile time link together into the executable file, which means that we do not need to install a JVM like JAVA. And compile the executable file itself is not dependent on other DLL can be done easily released. Of course, if you use the GO written call some dynamic library interface code, you still need to deploy the DLL according to the actual situation. This is in many from python / java to go my friends, very much.

There is a better and more robust standard library. GO with standard library itself is more comprehensive, from document archiving, compression, encryption, database data serialization, character formatting and testing, and network libraries, library sync everything. Basically able to meet many basic needs. Even better, the quality of these standard libraries are very high, very strong. The interface is relatively simple, there is clearly documented. Meanwhile, with two years of development, GO third-party libraries have sprung up, though probably not as much as the python, but less time for its development, is still very good.

Integration testing framework. When before writing code in C ++, write unit tests it is not an easy task. It requires some skill and effort before they can do it. However, integrated unit testing framework in the GO, as long as the source file to _test.go end, you can directly go test execution unit tested. It also offers code coverage testing tool, you can easily implement automated testing. In addition, it incorporates benchmarking framework function, you can easily write their own operating efficiency measurement function. In addition, performance profiler, you can run, test analysis bottleneck point in the program, and thus can be optimized.

Sound and style code checking tool. GO had to learn, a lot of articles and books will mention this go fmt command, unified code style. I felt this really solve the style of the other. The impact of the code is written by someone else wrote it myself feeling is the same. There golint, go team can follow the style and requirements to write code. There go vet can be used to check some very subtle GO pit.

Simple but powerful package management. GO package management package management may be in many other languages ​​it seems weak, but in my opinion, it solves two problems I need, is a circular dependency issue, GO package is rejected there is a circular dependency relationship; Second, the initialization packet, each packet can achieve a document init function to execute when importing. This is very useful when the division of labor.

Easy to write cross-platform code. If you use pure GO, do not involve CGO, you can be very easy to do cross-platform. Just before the file suffix .go, introduced _linux, _windows, _x86, _x64 characters such as the end of the file name prefix can be done only compiled in the corresponding platform. GO also build constraints control code compilation under what conditions. If you use the CGO, will involve a cross-platform C, so it is some little trouble, but the problem is not too large.

Garbage collection. GC presence greatly reduces the writing concurrent code, but also provides a robustness of the program. ++ From the start as a C / C, have been driving the development of experienced programmers, GC this thing that I have not covered before. For me GC is equivalent to a nightmare. But when I began to try to find acceptable GC, GC really solve the programmer productivity, greatly improving efficiency. Although it has GO 1.4 version, but may not be on GC still outstanding, in accordance with GO roadmap, will be behind the GC to achieve better added.

Interface struct. In the first study of GO interface, my first reaction is that this is what I want. Although many people are saying GO this interface is not good, but said makes sense, such as Zhao's "Why I do not like the language GO style interface." interface can be extended to a combination of the new interface, struct combination can also be extended to the new struct. Not inherited, only the combination. You can achieve a similar effect by anonymous inherited portfolio. Interface can be queried, somewhat similar to the COM taste, but easier on the grammatical level. struct to interface mappings are implicit, not need to declare a struct implements an interface. While the name may appear on the conflict, but it can be resolved through the wrapper. Another advantage of this interface is very easy to implement MOCK unit testing, it is very fond of. You can also see the article "Go interfaces make test stubbing easy"

Unified work layout. GO defines the directory structure of the project, such as bin directory, pkg directory and src directory. This and my daily project layout is the same. Before using C ++ development when we are so arranged layout, so on this point, I felt easy transition.

Built-in concurrency primitives. GO mentioned have to mention goroutine and channel. Cheap and cheerful goroutine allows us to handle asynchronous tasks, channel can be used to exchange data. With goroutine, you can easily achieve high-performance server. goroutine its scheduler may easily and EPOLL, IOCP mechanism combined with other systems, and through Half Sync / Half Async mode, it is easy to achieve synchronization in the form of syntax level, but without losing performance.

In early 2013, when still doing a client, then use the C ++ 0x, which impressed me most things lambad, std :: function / bind, combined with the thread + queue, it can be very easy to achieve similar Chromuim threading model. In dealing with slow UI tasks such as reading documents, data and other interactive web request, in order to ensure UI experience, these asynchronous tasks is the very necessary. If you have to Golang understanding or familiar friends will understand that this is similar to Golang of goroutine + channel. However, when using this model, still felt a bit tedious, I want to pay attention to the object's life cycle, this in C ++, although there are a variety of smart pointers help, but inevitably will not exhaustive. And encountered a little complicated problems, such as a slow task followed by a slow task, it will involve a task chain, (Facebook folly open source library has a good realization futures in no future / promise, and later also found WINDOWS there actor model-based concurrency library Asynchronous Agents library is very good, but unfortunately currently used only on WINDOWS.) assistance under the mechanism easily enter Callback Hell. This will lead to code relatively difficult to maintain, and easy to breed BUG. Fortunately, this was part of the code is not too much and is not too complicated, it is easy to stabilize by the self-test.

Although the above mentioned future / promise, AAL can solve some problems Callback Hell, but future still like to use callback. So I was wondering if you can do it is on the code level synchronous, asynchronous behind it is just cool. GO would meet my needs.

GO standard library also provides a sync package, including basic mutex he said, there RMutex this read-write lock, as well as Once, WaiterGroup other things. Basically meet the daily needs of the locks.

GO To help programmers to solve the race condition problem often encountered in concurrent, but also provides the appropriate tools to race condition. There are corresponding deadlock detection tool.

Although GO community has a slogan: "do not communicate by sharing memory; instead, share memory by communicating.", But between each goroutine not fully independent, the same can be done through shared memory data. This time can only rely on themselves to abide by the programmer. And because goroutine not fully independent, panic this kind of thing could cause the whole program to hang. This really is not very good and Erlang compared.

Egg pain defer. Accustomed to using the C ++ RAII after disgusted defer GO mechanism, but sometimes they have to use. The reason is that this is not defer block level, but the level of function, it is necessary before the function returns before they get implemented. So this process will result in something like the file open, then close the operation of logic is very boring, back to the C's, you must manually go Close.

Egg pain panic. Although I do not use exceptions, but for the panic that I was very dissatisfied with the design in C ++ ah. Because it will affect the overall situation. And to capture the panic on the need defer. If panic just let the current goroutine hang on Hi skin I felt bad.

Without generics. GO no generic bring boring place, or to use interface {} do runtime generics, or to manually write your own code generator. For example, I own in order to generate network protocol serialization code line and a generator. And because there is no generic, I would like to achieve a similar C ++ STL containers and algorithms basically not too likely, or some method of course, continue to use the code generator. GO1.4 altogether and introduce a call go generate commands.

to sum up

GO inside some other built-in data structures, such as slice, map, etc., but these are also criticized because it was not any give programmers can enjoy benefits range keyword.

In all of the features of the GO, the most favorite is the GC, goroutine, channel and interface. While the remaining features (such as the above I have cited many features) I felt is not too important, many of which are in engineering practice, and not so much the language itself.

To conclude, this thing is an engineering tool for a variety of easy to use, but speaking from a design point of view a variety of rough, no need overvalued. Engineering practice it counted good friend. When writing the service side, it is the weapon, at least when writing server program, I feel so.

A friend said that a language is good to see that there is no open up your horizons and give you new ideas, I think at this point at least GO satisfied.
     
         
       
         
  More:      
 
- CentOS6.5 install SVN & visual management tools iF.SVNAdmin (Server)
- Linux terminal interface font color settings (Linux)
- Sublime Text 3 using summary (Linux)
- MongoDB version 3.2 WiredTiger storage engine performance tests (Database)
- RedHat Linux source code package installation process (Linux)
- Calculate CPU utilization (Linux)
- Java regular expressions examples (Programming)
- Error: Unable to establish connection with FTP SFTP server (Server)
- Thinking in Java study notes - initialization and cleanup (Programming)
- CentOS6 install Redis (Database)
- MySQL time field based partitioning scheme summary (Database)
- Why is better than Git SVN (Linux)
- MySQL function: group_concat () function (Database)
- Zypper command for SUSE Linux package management (Linux)
- What happens after the MySQL disk space is full (Database)
- Developing a Web server yourself (Server)
- Storm how to assign tasks and load balancing (Programming)
- Modifying the system registry protection server security (Linux)
- Object-C in the preparation of multi-parameter function parameter is omitted (Programming)
- Android official recommendation: DialogFragment create dialog (Programming)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.