Created
September 27, 2018 12:52
-
-
Save shirou/a5ce02b7ba980a8456b9f252a325f240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"github.com/shirou/gopsutil/cpu" | |
"github.com/shirou/gopsutil/disk" | |
"github.com/shirou/gopsutil/host" | |
"github.com/shirou/gopsutil/mem" | |
) | |
func osInfo() { | |
c, _ := cpu.Info() | |
n, _ := host.Info() | |
i, _ := net.Interfaces() | |
v, _ := mem.VirtualMemory() | |
fmt.Println("cpu: ", c) | |
fmt.Println("host: ", n) | |
fmt.Println("net: ", i) | |
fmt.Println("mem: ", v) | |
path := "/" | |
if n.OS == "windows" { | |
path = "\\" | |
} | |
diskStat, _ := disk.Usage(path) | |
fmt.Println("disk: ", diskStat) | |
} | |
func main() { | |
osInfo() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment