util

package
v0.0.0-...-3c1c5df Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2025 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCommand

func CheckCommand(exe string) bool

CheckCommand 检查某个命令是否存在

  • exe 检查的命令

若命令存在返回true

func CheckFileSHA256

func CheckFileSHA256(filepath string) (string, error)

CheckFileSHA256 计算文件的SHA256的值

  • file 传入文件路径

返回文件的SHA256摘要

func ErrorExitAndDelay

func ErrorExitAndDelay(delay int)

ErrorExitAndDelay 在程序出现严重错误时,延迟几秒并退出 请注意,该函数将导致程序以状态码1退出

  • delay 退出之前延迟时间,单位s

func ExecuteByTerminal

func ExecuteByTerminal(args ...string) error

ExecuteByTerminal 调用系统默认终端执行一行命令 通过这种方式可以实现弹出终端执行对应命令,使命令的执行过程能够显现

  • args 运行的命令行

出现错误则返回错误对象

func FileExists

func FileExists(filePath string) bool

FileExists 判断文件是否存在

func GetSystemTerminal

func GetSystemTerminal() (string, error)

GetSystemTerminal 检查系统的终端

返回系统安装的一个终端程序,否则返回错误对象

func MkdirIfNotExists

func MkdirIfNotExists(folder string) error

MkdirIfNotExists 创建文件夹如果文件夹不存在

  • folder 文件夹路径

func MoveFile

func MoveFile(origin, destination string) error

MoveFile 移动文件,如果目标目录已存在同名文件,则自动重命名

  • origin 原始文件路径
  • destination 移动后文件路径

func RemoveArgs

func RemoveArgs(origin []string, remove ...string) []string

RemoveArgs 从命令行参数切片中移除某些参数

  • origin 原始参数列表
  • remove 要移除的参数列表

返回移除对应参数后的参数列表

Types

This section is empty.

Jump to

Keyboard shortcuts

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