What are the advantages of Go?

1. Fast compilation

In the past, when compiling Java projects, some large projects, with a lot of dependencies, may take a few minutes or even 10 minutes to start a project, resulting in development tests as an excuse to drift. Now Go compilation logic only refers to the dependent libraries, not all the libraries traversal, compilation efficiency is greatly improved, in other words, Go programmers are helpless pain.

2. Good concurrency performance

With a large number of Internet, cloud computing, a large number of visits to the project continues to be popular, a product experience is good or bad, very intuitive response is the speed of response. Goroutines in Go take up less memory than threads and have a built-in channel data structure that allows you to interact with different Goroutines through channels. A Goroutine can be executed in parallel with other Goroutines. In other programming languages, a single thread is used to perform tasks. In GO, a single thread is used to control multiple Goroutines to perform tasks.

For example, a person wants to go to the canteen to have a meal, can call a number first, and then go to find a position to play mobile phone, code into the next

func eat(){ … }

func play(){ … }

main(){

go eat();

go play;

. }

The eat and play methods are executed in parallel.

The channel is the interaction between goroutine. If A Goroutine is in the dining queue, and B Goroutine is outside playing with mobile phone and watching short videos, A can send A message to B through the channel. It’s time for us to sit in and eat.

It should be noted that when A knows the message that A can have dinner, B cannot be informed of it. What means is that A and B are shielded and need to synchronize through A specified method.