os/platform
Identifying the system the program is running on: the operating system, the processor, the core count and the memory.
import os.platform
The os.platform package says at run time what system the program is on. For decisions that belong at compile time, constants such as SALAM_OS_WINDOWS and conditional compilation are the better fit; this package is for reports, automatic settings and messages.
The example below prints whether the properties hold rather than the system's name, so that its output is the same everywhere.
Functions
IsLinux
func IsLinux(): boolimport os.platform
func main:
known := platform.IsLinux() or platform.IsWindows() or platform.IsMac() or platform.IsFreeBSD() or platform.IsBSD() or platform.IsAndroid() or platform.IsWasm()
println known, platform.OS().len() > 0
arch := platform.IsX64() or platform.IsArm64() or platform.IsX86() or platform.IsArm()
println arch, platform.Arch().len() > 0
println platform.CpuCount() >= 1
println platform.TotalMemory() > 0, platform.AvailableMemory() <= platform.TotalMemory()
endIsWindows
func IsWindows(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
IsMac
func IsMac(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
IsBSD
func IsBSD(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
IsFreeBSD
func IsFreeBSD(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
IsAndroid
func IsAndroid(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
IsWasm
func IsWasm(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
OS
func OS(): strlinux, mac, windows, freebsd, android or wasm.The example for this item is shown with the ones above: os-platform-OS.salam
IsX64
func IsX64(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
IsArm64
func IsArm64(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
IsX86
func IsX86(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
IsArm
func IsArm(): boolThe example for this item is shown with the ones above: os-platform-OS.salam
Arch
func Arch(): strx64 or arm64.The example for this item is shown with the ones above: os-platform-OS.salam
CpuCount
func CpuCount(): intThe example for this item is shown with the ones above: os-platform-OS.salam
TotalMemory
func TotalMemory(): i64The example for this item is shown with the ones above: os-platform-OS.salam
AvailableMemory
func AvailableMemory(): i64The example for this item is shown with the ones above: os-platform-OS.salam