Go language can be used as backend. Go language is a server-side programming language. Its direction is mainly back-end. It is very suitable for processing logs, data packaging, virtual machine processing, file systems, distributed systems, database agents, etc. The reasons for using Go language for back-end development: 1. It has the characteristics of concise syntax and high execution efficiency at the language level; 2. It focuses on concurrency and is born for concurrency. Its starting point is to target high-level applications in the era of big data and cloud computing. Concurrent and distributed application scenarios; 3. It can be directly compiled to generate executable programs on different platforms, and the basic memory usage is very small.
The operating environment of this tutorial: Windows 7 system, GO version 1.18, Dell G3 computer.
Go language is a server-side programming language, mainly used for back-end. It is very suitable for processing logs, data packaging, virtual machine processing, file systems, distributed systems, database agents, etc.
Why use Go language for back-end development?
1. Simple and efficient: Almost all mainstream programming languages such as Java, C, PHP, Python, JavaScript, etc. can be used for server-side development. Go language is a rising star. At the language level, it has the characteristics of simple syntax and high execution efficiency (underlying language); in comparison, Java, Python, and PHP are all inefficient, C is too troublesome, and Go can achieve both simplicity and efficiency;
2. High concurrency: Go language focuses on concurrency and is born for concurrency. Its starting point is to target high concurrency and distributed application scenarios in the era of big data cloud computing;
3 , Cross-platform: It can be directly compiled to generate executable programs on different platforms. The basic memory usage is very small. Small applications take up a few M and large applications take up dozens of M and can run well. This allows golang to be used on Raspberry Pi and the like. It runs very well on small devices, which performs much better than Java;
Containerization, distribution, and microservices are the trends in server development, in these directions:
Containerization: Go language is the absolute overlord in the container field. The well-known Docker and Kubernets (K8S) are developed using Go language;
Distribution Formula: The best example is Ethereum, because the blockchain is a distributed ledger;
Microservices: The best example of Go language supporting microservices is Toutiao, which is currently More than 80% of the traffic of back-end services runs on services built in Go. The number of microservices exceeds 100, the peak QPS exceeds 7 million, and the daily processing request volume exceeds 300 billion. It may be the largest Go application in the industry.
# Go language is a back-end language. Compared with other back-end languages, what are the advantages or characteristics of Go?
# The language level supports concurrency. This is the biggest feature of Go. It is easy to write multi-threaded programs and can make full use of multiple cores.
As a programming language born in the 21st century, it supports garbage collection. Like Java, developers do not need to manage memory and can focus on business implementation.
Rich standard library, Go has a large number of built-in libraries, especially the network library is very powerful.
Go language deployment is relatively simple, directly compiled into machine code, and there are cross-platform compilation options.
The philosophy of Go language is "less is more". Compared with C and Java, Go language is easier to get started.
Go language success story
1. Docker (container)
Up to now, Docker It is almost a success story that is hard to find and copy in Go. The Docker project received $40 million in Series C financing in September 2014. The version iteration speed is super fast. Currently, there are 78 versions seen on GitHub, and it is only a project that was officially started in early 2013. At present, domestic Docker technology promotion is also in full swing, such as the Docker Chinese community, and CSDN has also established a Docker zone. The reason why the Docker team likes to use the Go language is mainly because Go has a powerful standard library, a full development environment, and the ability to build cross-platforms.
2. Kubernetes (container)
Kubernetes is Kubernetes launched by Google in the summer of 2014. It is based on Docker and its purpose is to allow users to manage cloud container clusters through Kubernetes clusters without the need for users to Perform complex setup work. The system will automatically select appropriate working nodes to perform specific container cluster scheduling and processing work. Its core concept is Container Pod.
3. Etcd & Fleet (distributed database)
etcd is a key-value storage system developed and maintained by CoreOS. It is written in Go language and handles log replication through Raft consistency algorithm. Ensure strong consistency. Currently, Google's container cluster management system Kubernetes, open source PaaS platform Cloud Foundry and CoreOS' Fleet all use etcd extensively. Fleet is a distributed initialization system. The reason why they choose to use the Go language is because of the good cross-platform support of the Go language and the strong community behind it.
4. Deis (cloud service platform)
Deis is an open source PaaS platform based on Docker and CoreOS, designed to make it easy to deploy and manage applications on servers. It can run on AWS, GCE and Openstack platforms.
5. Flynn (Cloud Service Platform)
Flynn is an open source PaaS platform written in Go language, which can automatically build and deploy any application to run on a Docker container cluster. The Flynn project is supported by Y Combinator and is still under development. It is called the next generation open source PaaS platform.
6. Lime (desktop application)
Compared with the above Go languages in addition to the cloud and server side, Lime is quite special. Lime is a desktop editor program written in Go language, which is regarded as an open source implementation of the famous editor Sublime Text.
7. Revel (Web Framework)
Revel is a highly productive Go language Web framework. The Revel framework supports hot compilation. When editing, saving and refreshing the source code, Revel will automatically compile the code and templates; full-stack features support routing, parameter parsing, caching, testing, internationalization and other functions.
8. InfluxDB (distributed database)
An open source distributed timing, event and indicator database written in Go voice, without external dependencies. Its design goal is to achieve distributed and horizontal scaling.
9. .Syncthing (cloud disk)
An open source cloud storage and synchronization service tool written in Go language. Users’ data will be fully controlled by themselves, and all communications will be encrypted. Each access node is authenticated with an encryption certificate. The project is considered an open source alternative to Dropbox and BitTorrent Sync. The reason why Syncthing chose the Go language is also due to cross-platform considerations.
10. Gogs (self-service Git service)
Gogs is a self-service Git service project developed by Guoren Wuwen (GitHub). The goal of Gogs is to create the simplest, fastest and easiest way to build self-service Git services. According to the author, the reason for choosing to use the Go language for development is that Go allows Gogs to be distributed through independent binaries and has good support for cross-platforms.
Go back-end development prospects
Taking Imperial City as an example, the salary of Go development engineers in random samples is as low as 10K and as high as 10K. To 60, most areas fall within the 20K-40K range;
Go What is the current mainstream employment direction in the industry?
First of all, in the Web field, Go can do whatever Java/php can do, and it is simpler and more efficient;
In the following scenarios, Go is particularly prominent as a language Advantages:
Scenarios that require high efficiency: For example, recommendation engines must quickly form user portraits based on big data analysis and generate recommended content - so Toutiao's recommendation engine uses Go Do it;
Complex algorithm scenarios: such as big data sorting, which used to be done with C/C, but now can be done with Go;
High concurrency scenario: A server-side executable program developed in Go language can withstand millions of concurrency, while Java needs to use more servers for load balancing, which increases the cost;
Distributed scenarios: especially large-scale distributed scenarios, or server nodes that plan to join the blockchain;
[Related recommendations: Go video tutorial、Programming teaching】
The above is the detailed content of Can go language be used as backend?. For more information, please follow other related articles on the PHP Chinese website!