helpers

package
v0.0.0-...-0ec59c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsLogToFileEnabled = false

Functions

func CheckRootPrivileges

func CheckRootPrivileges()

func EnableLogToFile

func EnableLogToFile(fileName string)

启用记录到文件

func GetAssemblyFolder

func GetAssemblyFolder() string

return the absolute path of folder which contains current assembly file

func GetNowTimestamp

func GetNowTimestamp() int64

func HttpGet

func HttpGet(url string) (string, error)

func IdleAnimation

func IdleAnimation()

func IsFileExist

func IsFileExist(fullPath string) bool

检查文件是否存在。如果文件不存在,返回false。 什么时候用这个而不用os.Stat()? 因为os.Stat() 不能判断挂载的文件是否存在

func IsProgressRunning

func IsProgressRunning(progressName string) bool

func KillProgressByName

func KillProgressByName(progressName string, retryMax int) bool

func KillProgressByPort

func KillProgressByPort(port string, protocal string, retryMax int) bool

func LogError

func LogError(v ...any)

func LogFatal

func LogFatal(v ...any)

func LogInfo

func LogInfo(v ...any)

func LogOK

func LogOK(v ...any)

func LogWarning

func LogWarning(v ...any)

func RunCommandLine

func RunCommandLine(printError bool, command string, args ...string) bool

func RunCommandLineAndPrintOutput

func RunCommandLineAndPrintOutput(cmd string)

func RunCommandLineWithPip

func RunCommandLineWithPip(command string, pip string, printError bool) bool

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 ToBlueString(str string) string

func ToGreenString

func ToGreenString(str string) string

func ToOrangeString

func ToOrangeString(str string) string

func ToPurpleString

func ToPurpleString(str string) string

func ToRedString

func ToRedString(str string) string

func ToYellowString

func ToYellowString(str string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL