This is a creation in Article, where the information may have evolved or changed.
first, go language advantage
- Can be directly compiled into machine code, go compilation generated is a static executable file, in addition to glibc outside the external dependencies
- Statically typed language, but with a sense of dynamic language
- Concurrency is supported at the language level. Goroutine and channel make it easy to write high-concurrency server-side software, and in many cases there is no need to consider locking mechanisms and the various problems that arise. A single go application can also effectively utilize multiple CPU cores, performing well in parallel execution
- Built-in runtime, supports garbage collection
- Cross-platform compilation
- Inline C Support
- Easy to learn, the Go keyword is 25, but the expressive power is strong and almost supports most of the features you've seen in other languages: inheritance, overloading, objects, etc.
- Retain but significantly simplify pointers
- Multi-parameter return
- Array,slice,map and other built-in basic data structures
- Interface any data structure, as long as the implementation of Interface defined functions, automatically implement this Interface
second, the go language can be qualified for what work?
- Server programming, such as processing logs, data packaging, virtual machine processing, file systems, etc.
- Distributed systems, database proxies, etc.
- Network programming, including Web applications, API applications, download applications
- In-memory database
- Cloud Platform
third, go language defects
- Go import package does not support version, sometimes upgrade is easy to cause project not to run
- Go Goroutine once started, the switch between different goroutine is not controlled by the program, runtime scheduling, the need for rigorous logic
- Large GC Delay
Iv. Success Stories
- Docker
five, in-depth understanding of the concurrency of Go syntax sugar
The concurrency syntax sugar for Go is mainly related to the three problems of large concurrency (massive concurrency), competitive conditions (race condition), error handling (err handling).
- In the big concurrency aspect, go solves very well, the essence is user-space thread.
- The basic idea of the go-to-chan channel is to ensure that each logical flow uses a separate memory space, restricting some constrained methods to communicate. But for efficiency reasons (which require a copy operation to deliver a message), there is no guarantee of coercion and it is still easy to access shared memory. The correctness of the program depends only on the correct use of the programmer and strict adherence to slogan.
- In Go, the co-process is not completely independent (no process isolation) for the lack of localization capability (no identity) for the created process. When a system exception occurs (for example, in addition to 0), the entire program is dropped and the state fallback and recovery operation is not possible.