Go语言学习之runtime包(The way to go)

拼搏现实的明天。 2022-06-17 12:44 309阅读 0赞

生命不止,继续 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

  1. func NumCPU() int

GOROOT
GOROOT returns the root of the Go tree

发表评论

表情:
评论列表 (有 0 条评论,309人围观)

还没有评论,来说两句吧...

相关阅读