Runtime package variables
Below is a short program to display compiler, number of cpu, language version, GOOS, GOARCH, and GOROOT at run-time.
Example
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Printf("\nGOOS:%s", runtime.GOOS)
fmt.Printf("\nGOARCH:%s", runtime.GOARCH)
fmt.Printf("\nGOROOT:%s", runtime.GOROOT())
fmt.Printf("\nCompiler:%s", runtime.Compiler)
fmt.Printf("\nNo. of CPU:%d", runtime.NumCPU())
}
Output
GOOS:windows
GOARCH:386
GOROOT:C:\Go
Compiler:gc
No. of CPU:1
Most Helpful This Week
Copy an array by value and reference into another array
How to write backslash in Golang string?
Get Year, Month, Day, Hour, Min and Second from current date and time.
Subtract N number of Year, Month, Day, Hour, Minute, Second, Millisecond, Microsecond and Nanosecond to current date-time.
How to check if a string contains a numbers in Golang?
Golang HTML parser