Skip to content

Instantly share code, notes, and snippets.

@shirou
Created September 27, 2018 12:52
Show Gist options
  • Save shirou/a5ce02b7ba980a8456b9f252a325f240 to your computer and use it in GitHub Desktop.
Save shirou/a5ce02b7ba980a8456b9f252a325f240 to your computer and use it in GitHub Desktop.
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