What is Go/golang? Why use the Go language? What are the advantages of the Go language? Go Language Primer

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

Author: Sophos

Links: https://www.zhihu.com/question/21409296/answer/47481548

Source: Know

Background

Prior to contacting Golang, I used C + +, LUA and Python as the main development language.

Problems with C + +:

Low development efficiency, high demand for developers

LIBC only backwards compatible, the operation of the difficulty is too large

Lua/python's question:

Dynamic language, lack of compilation process, low-level error frequency

Lack of effective performance analysis and debugging tools

Scene

Just completed the development of Nginx WAF module, began to set up a WAF management system. As the fluentd used by colleagues as a log collection component, I chose fluentd to maintain the consistency of the underlying components. That is, the final architecture is fluentd->mongodb->mysql, and then the front-end data display based on MySQL. After being dug up many times, I decided to rewrite fluentd with go to solve the following problems:

Fluentd in Ubuntu 9.04 occasionally appears suspended animation, resulting in data loss

Fluentd difficult to access the company's existing package release system, resulting in a very difficult operation

MongoDB is implemented with MMAP, which consumes too much memory when the data volume is large

Scheme

Please click here for the Gofluent code.

Please click here for the HTTPMQ code.

In fact, all two of these projects are designed to address the above mentioned issues. Perhaps you do not believe, these two sets of code is I finished in my spare time, that is, it is not counted within the KPI. Actually at the beginning I did not expect to be able to write so quickly 7788, after all, is now learning to use AH. But the reality is, I spent a week writing HTTPMQ, one months more time to write the gofluent ... Of course, there are a lot of imperfections in these two projects. For the current log collection scenario, I would recommend Elastic/logstash-forwarder GitHub and Elastic/logstash Use with GitHub.

Why Choose Golang

So, why would I choose Golang? In fact, I've spent a lot of time doing detailed research before making this choice. Foreign such as Google, AWS, Cloudflare, CoreOS, etc., domestic such as seven cattle, Ali, etc. have begun to use Golang to develop their cloud computing related products. Follow the footsteps of world-class giants should not go in the wrong direction, and in the process of learning Golang, I have gradually been the design philosophy behind it.

In addition, the Cloud wind blog has said such a sentence:

I found that it took me four years to temper my ability to build a system in C language, trying to find a specification that could better write software. It turned out to be just a parody of Go. The lack of language support can only be a parody.

Here is my superficial understanding of Golang:

With C Foundation, learning Golang is very easy

Synchronous mode for high concurrency with ease

Simple code, uniform format, easy to read

Strong performance, and development efficiency is not worse than Python and other dynamic languages

Effect

The first ready to go online when in fact the mind quite disturbed, after all, if there is a failure, not only the bag to his back, face also on the wrong AH. Fortunately the result is pretty, since the launch did not appear a sudden bug, reduce the difficulty of operation and reduce the load of the machine.

All in all, from an engineering standpoint, choosing Golang is a very smart choice for most background applications. This makes it easy to take into account the operational performance, development efficiency and maintenance difficulty of the three great many programs ape desire to die of singularity.

Related Learning materials:

Data portal

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.