生命不止,继续 go go go !!!
今天跟大家分享一下runtime package,主要是介绍几个经常用到的方法。
runtime
Package runtime contains operations that interact with Go’s runtime system, such as functions to control goroutines. It also includes the low-level type information used by the reflect package; see reflect’s documentation for the programmable interface to the run-time type system.
上面是官方文档的介绍,我们看到几个关键字:
runtime system
control goroutines
low-level information
其中,goroutines我们还没有详细的介绍,这里暂时不表。
介绍几个跟平台有关的方法:
NumCPU
查看有多少个逻辑cpu, logical cpus
func NumCPU()