Go Notes: Difference between revisions

From Federal Burro of Information
Jump to navigationJump to search
(Created page with " == NumCPU() == How many cpu's does my pod see? tmp.go <pre> package main import "fmt" import "runtime" func main() { var i interface{} = runtime.NumCPU() fmt.Prin...")
 
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:


How many cpu's does my pod see?
How many cpu's does my pod see?
kubectl exec -it $pod -- /bin/bash
apt-get update
apt-get install golang


tmp.go
tmp.go
Line 17: Line 22:
}
}
</pre>
</pre>
go run tmp.go


<pre>
<pre>
16
$ go run tmp.go
8
hello world
hello world
</pre>
</pre>
The answer is 8 , same as what I see if I look in /proc/cpuinfo in the pod.

Latest revision as of 20:18, 3 March 2021

NumCPU()

How many cpu's does my pod see?

kubectl exec -it $pod -- /bin/bash

apt-get update
apt-get install golang

tmp.go

package main

import "fmt"
import "runtime"

func main() {
    var i interface{} = runtime.NumCPU()
    fmt.Printf("%v\n", i)
    fmt.Println("hello world")
}
$ go run tmp.go
8
hello world

The answer is 8 , same as what I see if I look in /proc/cpuinfo in the pod.