// $KyokoNet: antifetch, v 0.1.6 2022/11/15 08:54:00 akoizumi Exp $ // // Get current system information like neofetch(1) without fancy things. // It mostly uses the standard library, and an extra dependency. package main import ( "fmt" "os" "log" "runtime" "github.com/shirou/gopsutil/v3/host" "github.com/shirou/gopsutil/v3/mem" ) func main() { hostname, err := os.Hostname() uptime, _ := host.Uptime() v, _ := mem.VirtualMemory() days := uptime / (60 * 60 * 24) hours := (uptime - (days * 60 * 60 * 24)) / (60 * 60) minutes := ((uptime - (days * 60 * 60 * 24)) - (hours * 60 * 60)) / 60 if err != nil { log.Fatal(err) } fmt.Printf("%s @ %s\n", os.Getenv("USER"), hostname) fmt.Printf("\n") fmt.Printf("Editor:\t%s\n", os.Getenv("EDITOR")) fmt.Printf("System:\t%s\n", runtime.GOOS) fmt.Printf("Architecture:\t%s\n", runtime.GOARCH) fmt.Printf("RAM:\t%v/%v (%f%%)\n", v.Total, v.Free, v.UsedPercent) fmt.Printf("Shell:\t%s\n", os.Getenv("SHELL")) fmt.Printf("Uptime:\t%dd:%dh:%dm\n", days, hours, minutes) }