update v-advance

This commit is contained in:
lzx
2025-12-01 15:45:05 +08:00
parent 16173b7ccd
commit de010e39ee
22 changed files with 1963 additions and 175 deletions

View File

@@ -0,0 +1,12 @@
//go:build linux
package utils
import "os"
// IsAdmin 检测当前用户是否为 rootUID=0
func IsAdmin() bool {
return os.Geteuid() == 0
}

View File

@@ -0,0 +1,20 @@
//go:build windows
package utils
import (
"os/exec"
)
// IsAdmin 检测当前用户是否为管理员。
// 通过执行 `net session` 命令判断:该命令只有在管理员权限下才会成功。
func IsAdmin() bool {
cmd := exec.Command("net", "session")
// 不关心输出,只关心能否成功执行
if err := cmd.Run(); err != nil {
return false
}
return true
}