GopherSnippetsStar

Code snippets with tests and testable examples for the Go programming language

How to print information about the operating system, architecture and pointer size

Snippets Index - Run code on Go playground - Edit

package main

import (
	"fmt"
	"runtime"
	"unsafe"
)

func Example() {
	fmt.Printf("running program's operating system target: %s\n", runtime.GOOS)
	fmt.Printf("running program's architecture target: %s\n", runtime.GOARCH)
	var ptr uintptr
	ptrSize := int(unsafe.Sizeof(ptr))
	fmt.Printf("pointer size: %d\n", ptrSize)
	// Output:
	// running program's operating system target: linux
	// running program's architecture target: amd64
	// pointer size: 8
}

by psampaz - source code - comment below or here