Add CPU detection in mac

This commit is contained in:
Lea Anthony 2023-09-05 23:14:18 +10:00
commit b140ce546f
3 changed files with 14 additions and 0 deletions

View file

@ -27,6 +27,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/pterm/pterm v0.12.51
github.com/samber/lo v1.38.1
github.com/shoenig/go-m1cpu v0.1.6
github.com/tc-hib/winres v0.1.6
github.com/wailsapp/go-webview2 v1.0.6-0.20230901120557-e959fdf1ccc3
github.com/wailsapp/mimetype v1.4.1

View file

@ -312,6 +312,10 @@ github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXn
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=

View file

@ -9,6 +9,14 @@ import (
"syscall"
)
func getSysctl(name string) string {
value, err := syscall.Sysctl(name)
if err != nil {
return "unknown"
}
return value
}
func getInfo() (map[string]string, bool) {
result := make(map[string]string)
ok := true
@ -21,6 +29,7 @@ func getInfo() (map[string]string, bool) {
appleSilicon = lo.Ternary(r == "\x00\x00\x00" || r == "\x01\x00\x00", "true", "false")
}
result["Apple Silicon"] = appleSilicon
result["CPU"] = getSysctl("machdep.cpu.brand_string")
// Check for xcode command line tools
output, err := exec.Command("xcode-select", "-v").Output()