In the Go programming language, to get the system information using syscall – we use the Sysinfo() function of the syscall package. The Sysinfo() function is used to get the system information. It returns (assigns) the following information in the Sysinfo_t structure and Sysinfo_t contains the following fields:
type Sysinfo_t struct {
Uptime int64
Loads [3]uint64
Totalram uint64
Freeram uint64
Sharedram uint64
Bufferram uint64
Totalswap uint64
Freeswap uint64
Procs uint16
Pad uint16
Pad_cgo_0 [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
X_f [0]byte
Pad_cgo_1 [4]byte
}
Syntax:
Consider the below example demonstrating how to get the system information using syscall in Golang?
Output
sysinfo: {8 [0 0 0] 104857600 74522624 0 0 0 0 15 0 [0 0 0 0] 0 0 1 [] [0 0 0 0]} Uptime: 8 Loads: [0 0 0] Totalram: 104857600 Freeram: 74522624 Sharedram: 0 Bufferram: 0 Totalswap: 0 Freeswap: 0 Procs: 15 Pad: 0 Pad_cgo_0: [0 0 0 0] Totalhigh: 0 Freehigh: 0 Unit: 1 X_f: [] Pad_cgo_1: [0 0 0 0]need an explanation for this answer? contact us directly to get an explanation for this answer