Shixiang Wang

>上士闻道
勤而行之

godoc 查看函数文档和源代码

王诗翔 · 2021-03-12

分类: golang  
标签: go   godoc  

这个非常有意思,感觉和 R 的文档查看和使用完全是不一样的风格。

$ go doc runtime NumCPU
$ go doc -src runtime NumCPU

查看效果:

▶ go doc runtime NumCPU
package runtime // import "runtime"

func NumCPU() int
    NumCPU returns the number of logical CPUs usable by the current process.

    The set of available CPUs is checked by querying the operating system at
    process startup. Changes to operating system CPU allocation after process
    startup are not reflected.
    
▶ go doc -src runtime NumCPU
package runtime // import "runtime"

// NumCPU returns the number of logical CPUs usable by the current process.
//
// The set of available CPUs is checked by querying the operating system
// at process startup. Changes to operating system CPU allocation after
// process startup are not reflected.
func NumCPU() int {
        return int(ncpu)
}