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
How to read names of all files and folders in current directory?
How to convert Colorful PNG image to Gray-scale?
How to import and alias package names?
Regex to extract image name from HTML in Golang
How to check pointer or interface is nil?
How to Draw a rectangle in Golang?
Example: Arrays of Arrays, Arrays of Slices, Slices of Arrays and Slices of Slices
Dereferencing a pointer from another package
Example Function that takes an interface type as value and pointer?
Golang Slice interface and array concatenation