mirror of
https://github.com/oneclickvirt/basics.git
synced 2025-10-08 18:11:02 +08:00
v0.0.4 - 更新适配MAC系统和类BSD系统
This commit is contained in:
24
system/macos.go
Normal file
24
system/macos.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/oneclickvirt/basics/model"
|
||||
)
|
||||
|
||||
func isMacOS() bool {
|
||||
out, err := exec.Command("uname", "-a").Output()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
systemName := strings.ToLower(string(out))
|
||||
return strings.Contains(systemName, "darwin")
|
||||
}
|
||||
|
||||
func getMacOSInfo() {
|
||||
out, err := exec.Command("system_profiler", "SPHardwareDataType").Output()
|
||||
if err == nil && !strings.Contains(string(out), "error") {
|
||||
model.MacOSInfo = strings.Split(string(out), "\n")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user