forked from jaypipes/ghw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (51 loc) · 901 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Use and distribution licensed under the Apache license version 2.
//
// See the COPYING file in the root project directory for full text.
//
package ghw
const (
UNKNOWN = "unknown"
)
type HostInfo struct {
Memory *MemoryInfo
Block *BlockInfo
CPU *CPUInfo
Topology *TopologyInfo
Network *NetworkInfo
GPU *GPUInfo
}
func Host() (*HostInfo, error) {
info := &HostInfo{}
mem, err := Memory()
if err != nil {
return nil, err
}
info.Memory = mem
block, err := Block()
if err != nil {
return nil, err
}
info.Block = block
cpu, err := CPU()
if err != nil {
return nil, err
}
info.CPU = cpu
topology, err := Topology()
if err != nil {
return nil, err
}
info.Topology = topology
net, err := Network()
if err != nil {
return nil, err
}
info.Network = net
gpu, err := GPU()
if err != nil {
return nil, err
}
info.GPU = gpu
return info, nil
}