Documentation ¶
Index ¶
- Constants
- Variables
- func GetCurrentUserInfo() (*user.User, error)
- func GetHostname() string
- func GetLanguage() string
- func GetUserInfoById(userId int) (*user.User, error)
- func GetUserInfoByName(userName string) (*user.User, error)
- func GetVariable(key string) string
- func ProgramInfo() map[string]string
- func RunCommand(command string, args []string) error
- func RunCommandGetResult(command string, args []string) (string, error)
- func SetVariable(key, value string) error
Constants ¶
View Source
const ( Name string = "Scleaner" // 程序名 Version string = "v0.6.6" // 程序版本 Project string = "github.com/yhyj/scleaner" // 项目地址 )
Variables ¶
View Source
var ( FgBlackText = color.FgBlack.Render // 前景色 - 黑色 FgWhiteText = color.FgWhite.Render // 前景色 - 白色 FgLightWhiteText = color.FgLightWhite.Render // 前景色 - 亮白色 FgGrayText = color.FgGray.Render // 前景色 - 灰色 FgRedText = color.FgRed.Render // 前景色 - 红色 FgLightRedText = color.FgLightRed.Render // 前景色 - 亮红色 FgGreenText = color.FgGreen.Render // 前景色 - 绿色 FgLightGreenText = color.FgLightGreen.Render // 前景色 - 亮绿色 FgYellowText = color.FgYellow.Render // 前景色 - 黄色 FgLightYellowText = color.FgLightYellow.Render // 前景色 - 亮黄色 FgBlueText = color.FgBlue.Render // 前景色 - 蓝色 FgLightBlueText = color.FgLightBlue.Render // 前景色 - 亮蓝色 FgMagentaText = color.FgMagenta.Render // 前景色 - 品红 FgLightMagentaText = color.FgLightMagenta.Render // 前景色 - 亮品红 FgCyanText = color.FgCyan.Render // 前景色 - 青色 FgLightCyanText = color.FgLightCyan.Render // 前景色 - 亮青色 BgBlackText = color.BgBlack.Render // 背景色 - 黑色 BgWhiteText = color.BgWhite.Render // 背景色 - 白色 BgLightWhiteText = color.BgLightWhite.Render // 背景色 - 亮白色 BgGrayText = color.BgGray.Render // 背景色 - 灰色 BgRedText = color.BgRed.Render // 背景色 - 红色 BgLightRedText = color.BgLightRed.Render // 背景色 - 亮红色 BgGreenText = color.BgGreen.Render // 背景色 - 绿色 BgLightGreenText = color.BgLightGreen.Render // 背景色 - 亮绿色 BgYellowText = color.BgYellow.Render // 背景色 - 黄色 BgLightYellowText = color.BgLightYellow.Render // 背景色 - 亮黄色 BgBlueText = color.BgBlue.Render // 背景色 - 蓝色 BgLightBlueText = color.BgLightBlue.Render // 背景色 - 亮蓝色 BgMagentaText = color.BgMagenta.Render // 背景色 - 品红 BgLightMagentaText = color.BgLightMagenta.Render // 背景色 - 亮品红 BgCyanText = color.BgCyan.Render // 背景色 - 青色 BgLightCyanText = color.BgLightCyan.Render // 背景色 - 亮青色 InfoText = color.Info.Render // Info 文本 NoteText = color.Note.Render // Note 文本 LightText = color.Light.Render // Light 文本 ErrorText = color.Error.Render // Error 文本 DangerText = color.Danger.Render // Danger 文本 NoticeText = color.Notice.Render // Notice 文本 SuccessText = color.Success.Render // Success 文本 CommentText = color.Comment.Render // Comment 文本 PrimaryText = color.Primary.Render // Primary 文本 WarnText = color.Warn.Render // Warn 文本 QuestionText = color.Question.Render // Question 文本 SecondaryText = color.Secondary.Render // Secondary 文本 )
View Source
var ( GitCommitHash string = "Unknown" // Git 提交 Hash BuildTime string = "Unknown" // 编译时间 BuildBy string = "Unknown" // 编译者 )
View Source
var Arch = runtime.GOARCH // 系统架构
View Source
var (
ConfigFile = filepath.Join(configDir, programDir, configFile) // 配置文件路径
)
View Source
var Language = GetLanguage() // 系统语言
View Source
var Platform = runtime.GOOS // 操作系统
View Source
var Sep = string(filepath.Separator) // 路径分隔符
View Source
var UserInfo, _ = GetUserInfoByName(UserName) // 用户信息
View Source
var UserName = func() string { if GetVariable("SUDO_USER") != "" { return GetVariable("SUDO_USER") } return GetVariable("USER") }()
用户名,当程序提权运行时,使用 SUDO_USER 变量获取提权前的用户名
Functions ¶
func GetHostname ¶ added in v0.5.4
func GetHostname() string
GetHostname 获取系统 HOSTNAME
返回:
- HOSTNAME 或空字符串
func GetLanguage ¶ added in v0.6.5
func GetLanguage() string
GetLanguage 获取系统语言
返回:
- 系统语言,目前仅支持 zh 或 en
func GetUserInfoByName ¶ added in v0.5.4
GetUserInfoByName 根据用户名获取用户信息
参数:
- userName: 用户名
返回:
- 用户信息
- 错误信息
func RunCommandGetResult ¶
RunCommandGetResult 运行命令并返回命令的输出
参数:
- command: 命令
- args: 命令参数
返回:
- 命令的输出
- 错误信息
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.