Documentation ¶
Index ¶
- Variables
- func CheckRootPrivileges()
- func EnableLogToFile(fileName string)
- func GetAssemblyFolder() string
- func GetNowTimestamp() int64
- func HttpGet(url string) (string, error)
- func IdleAnimation()
- func IsFileExist(fullPath string) bool
- func IsProgressRunning(progressName string) bool
- func KillProgressByName(progressName string, retryMax int) bool
- func KillProgressByPort(port string, protocal string, retryMax int) bool
- func LogError(v ...any)
- func LogFatal(v ...any)
- func LogInfo(v ...any)
- func LogOK(v ...any)
- func LogWarning(v ...any)
- func RunCommandLine(printError bool, command string, args ...string) bool
- func RunCommandLineAndPrintOutput(cmd string)
- func RunCommandLineWithPip(command string, pip string, printError bool) bool
- func RunCommandLineWithSshOnRemoteServer(user, password, host, port, command string, timeout time.Duration) (string, error)
- func ToBlueString(str string) string
- func ToGreenString(str string) string
- func ToOrangeString(str string) string
- func ToPurpleString(str string) string
- func ToRedString(str string) string
- func ToYellowString(str string) string
Constants ¶
This section is empty.
Variables ¶
View Source
var IsLogToFileEnabled = false
Functions ¶
func CheckRootPrivileges ¶
func CheckRootPrivileges()
func GetAssemblyFolder ¶
func GetAssemblyFolder() string
return the absolute path of folder which contains current assembly file
func GetNowTimestamp ¶
func GetNowTimestamp() int64
func IdleAnimation ¶
func IdleAnimation()
func IsFileExist ¶
检查文件是否存在。如果文件不存在,返回false。 什么时候用这个而不用os.Stat()? 因为os.Stat() 不能判断挂载的文件是否存在
func IsProgressRunning ¶
func KillProgressByName ¶
func LogWarning ¶
func LogWarning(v ...any)
func RunCommandLineAndPrintOutput ¶
func RunCommandLineAndPrintOutput(cmd string)
func RunCommandLineWithPip ¶
example :
/sbin/ip link show ens33.1 | grep -q 'does not exist'
RunCommandLineWithPip("/sbin/ip link show ens33.1", "grep -q 'does not exist'", false)
func RunCommandLineWithSshOnRemoteServer ¶
func RunCommandLineWithSshOnRemoteServer(user, password, host, port, command string, timeout time.Duration) (string, error)
通过ssh通道在远程服务器上执行命令
example:
user := "root" password := "123456" host := "192.168.234.134" port := "22" command := "ls -al /root/Desktop; date" timeout := 2 * time.Second
output, err := RunCommandLineWithSshOnRemoteServer(user, password, host, port, command, timeout)
if err != nil { log.Fatal("Error executing command: ", err) }
fmt.Println("Command output:") fmt.Println(output)
func ToBlueString ¶
func ToGreenString ¶
func ToOrangeString ¶
func ToPurpleString ¶
func ToRedString ¶
func ToYellowString ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.