v1.16.0
ADDED: * tplx/sprigx
This commit is contained in:
47
tplx/sprigx/funcs_tpl_sys.go
Normal file
47
tplx/sprigx/funcs_tpl_sys.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package sprigx
|
||||
|
||||
import (
|
||||
`fmt`
|
||||
`runtime`
|
||||
)
|
||||
|
||||
// sysRuntime returns various information from [runtime].
|
||||
func sysRuntime() (out map[string]string) {
|
||||
|
||||
out = map[string]string{
|
||||
"compiler": runtime.Compiler,
|
||||
"arch": runtime.GOARCH,
|
||||
"os": runtime.GOOS,
|
||||
"maxprocs": fmt.Sprintf("%d", runtime.GOMAXPROCS(-1)),
|
||||
"cpu_cnt": fmt.Sprintf("%d", runtime.NumCPU()),
|
||||
"num_cgo": fmt.Sprintf("%d", runtime.NumCgoCall()),
|
||||
"num_go": fmt.Sprintf("%d", runtime.NumGoroutine()),
|
||||
"go_ver": runtime.Version(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// sysArch returns [runtime.GOARCH].
|
||||
func sysArch() (out string) {
|
||||
|
||||
out = runtime.GOARCH
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// sysNumCpu returns the reuslt from [runtime.NumCPU].
|
||||
func sysNumCpu() (out string) {
|
||||
|
||||
out = fmt.Sprintf("%d", runtime.NumCPU())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// sysOsNm returns [runtime.GOOS].
|
||||
func sysOsNm() (out string) {
|
||||
|
||||
out = runtime.GOOS
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user