runtime
Facts about the running program: the system, the memory, the uptime and the build options.
import runtime
The runtime package is useful for reporting a program's state, on a /health route on a server for instance. The uptime is counted from the moment MarkStart was called.
Free and used memory are available on Linux and Windows only; on other systems those functions return minus one.
Functions
OS
func OS(): strimport runtime
func main:
runtime.MarkStart()
println runtime.OS().len() > 0, runtime.Arch().len() > 0, runtime.CpuCount() >= 1
free := runtime.AvailableMemory()
used := runtime.UsedMemory()
println runtime.TotalMemory() > 0, free > 0 or free == -1, used >= 0 or used == -1
println runtime.UptimeMs() >= 0, runtime.UptimeSeconds() >= 0.0
println runtime.IsAsanBuild(), runtime.IsMemDebugBuild()
println runtime.IsSafeBuild() or not runtime.IsSafeBuild()
println runtime.BuildFlags().len() >= 0, runtime.Summary().len() > 0
endArch
func Arch(): strThe example for this item is shown with the ones above: runtime-Summary.salam
CpuCount
func CpuCount(): intThe example for this item is shown with the ones above: runtime-Summary.salam
TotalMemory
func TotalMemory(): i64The example for this item is shown with the ones above: runtime-Summary.salam
AvailableMemory
func AvailableMemory(): i64The example for this item is shown with the ones above: runtime-Summary.salam
UsedMemory
func UsedMemory(): i64The example for this item is shown with the ones above: runtime-Summary.salam
MarkStart
func MarkStart()main.The example for this item is shown with the ones above: runtime-Summary.salam
UptimeMs
func UptimeMs(): i64The example for this item is shown with the ones above: runtime-Summary.salam
UptimeSeconds
func UptimeSeconds(): f64The example for this item is shown with the ones above: runtime-Summary.salam
IsAsanBuild
func IsAsanBuild(): boolThe example for this item is shown with the ones above: runtime-Summary.salam
IsMemDebugBuild
func IsMemDebugBuild(): boolThe example for this item is shown with the ones above: runtime-Summary.salam
IsSafeBuild
func IsSafeBuild(): boolThe example for this item is shown with the ones above: runtime-Summary.salam
BuildFlags
func BuildFlags(): strThe example for this item is shown with the ones above: runtime-Summary.salam
Summary
func Summary(): strThe example for this item is shown with the ones above: runtime-Summary.salam