Home  >  Article  >  Backend Development  >  How many cores does golang run by default?

How many cores does golang run by default?

(*-*)浩
(*-*)浩Original
2019-12-27 10:36:314782browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn