Home>Article>Backend Development> How many cores does golang run by default?
Go (also known as Golang) is a statically strongly typed, compiled language developed by Google's Robert Griesemer, Rob Pike and Ken Thompson.
Go language syntax is similar to C, but its functions include: memory safety, GC (garbage collection), structural form and CSP-style concurrent computing. (Recommended learning:go)
golang uses single-core and single-thread by default. You can set multi-core and multi-thread support by adjusting or setting operating parameters
runtime.GOMAXPROCS(int) runtime.GOMAXPROCS(runtime.NumCPU()) 直接设置环境变量$GOMAXPROCS
Starting from version 1.5, Go uses multi-core execution by default. The default is the number of your CPU cores. In previous versions, the default was 1
The syntax of Go is close to the C language, but there are some restrictions on the declaration of variables. different.
Go supports garbage collection. Go's parallel model is based on Tony Hall's Communicating Sequential Process (CSP). Other languages that adopt a similar model include Occam and Limbo, but it also has features of Pi operations, such as channel transmission. Plugin support is opened in version 1.8, which means that some functions can now be dynamically loaded from Go.
Compared with C, Go does not include functions such as enumeration, exception handling, inheritance, generics, assertions, virtual functions, etc., but it adds slice type, concurrency, pipes, garbage collection, Language-level support for features such as interfaces.
Go 2.0 version will support generics, but has a negative attitude towards the existence of assertions, and also defends itself for not providing type inheritance.
Unlike Java, Go has built-in associative arrays (also known as hash tables (Hashes) or dictionaries (Dictionaries)), just like the string type.
The above is the detailed content of How many cores does golang run by default?. For more information, please follow other related articles on the PHP Chinese website!