system

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Reset  = "\033[0m"  // 重置颜色
	Red    = "\033[31m" // 红色
	Green  = "\033[32m" // 绿色
	Yellow = "\033[33m" // 黄色
	Blue   = "\033[34m" // 蓝色
)

Variables

This section is empty.

Functions

func Abs added in v1.0.10

func Abs(path string) (string, error)

Abs 获取绝对目录 与 filepath.Abs 的区别是,这个以可执行文件目录为工作目录

func CleanOldFiles

func CleanOldFiles(files []FileInfo, count int) (int, error)

func CompareVersionFunc

func CompareVersionFunc(a, b string, f func(a, b string) bool) bool

CompareVersionFunc 比较 ip 或 版本号是否一致

func ErrPrintf added in v1.0.12

func ErrPrintf(format string, a ...interface{})

ErrPrintf error output

func ExecCommand

func ExecCommand(ctx context.Context, args []string) ([]byte, error)

func Executable

func Executable() string

Executable 获取可执行文件绝对路径

func ExternalIP

func ExternalIP() (string, error)

ExternalIP 获取公网 IP

func GetDirSize

func GetDirSize(path string) (int64, error)

GetDirSize 获取目录大小,单位 Bit

func Getwd added in v1.0.10

func Getwd() string

Getwd 获取工作目录

func LocalIP

func LocalIP() string

LocalIP 获取本地IP地址

func PortUsed

func PortUsed(mode string, port int) bool

PortUsed 检测端口 true:已使用;false:未使用

func RemoveEmptyDirs

func RemoveEmptyDirs(rootDir string) error

RemoveEmptyDirs 删除空目录

func WarnPrintf added in v1.0.12

func WarnPrintf(format string, a ...interface{})

WarnPrintf warn output

Types

type FileBackup

type FileBackup struct {
	// contains filtered or unexported fields
}

func NewFileBackup

func NewFileBackup(file string) *FileBackup

func (*FileBackup) Close

func (f *FileBackup) Close()

func (*FileBackup) Write

func (f *FileBackup) Write(data []byte)

type FileInfo added in v1.0.10

type FileInfo struct {
	os.FileInfo
	Path string
}

func GlobFiles added in v1.0.10

func GlobFiles(path string) ([]FileInfo, error)

GlobFiles 按照升序排列所有文件

type Info

type Info struct {
	IP          string `json:"ip"`
	Pro         string `json:"pro"`        // 省;安徽省
	ProCode     string `json:"proCode"`    // 省区域代码;340000
	City        string `json:"city"`       // 城市;合肥市
	CityCode    string `json:"cityCode"`   // 城市代码;340100
	Region      string `json:"region"`     // 区域;蜀山区
	RegionCode  string `json:"regionCode"` // 区域代码;340104
	Addr        string `json:"addr"`       // 完整地址;安徽省合肥市蜀山区 电
	RegionNames string `json:"regionNames"`
	Err         string `json:"err"`
}

func IP2Info

func IP2Info(ip string) (Info, error)

Jump to

Keyboard shortcuts

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