Help us shape the future of Go! Take the 2026 Go Developer Survey

system

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

github.com/ixugo/netpulse 有更多关于 ip 的处理

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

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

func ErrPrintf(format string, a ...any)

ErrPrintf error output

func Executable

func Executable() string

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

func ExternalIP deprecated

func ExternalIP() (string, error)

Deprecated: 使用 github.com/ixugo/netpulse/ip 替代

func GetDirSize

func GetDirSize(path string) (int64, error)

GetDirSize 获取目录大小,单位 Bit 此操作根据目录大小,会占用较多内存,慎用

func Getwd

func Getwd() string

Getwd 获取工作目录

func LocalIP deprecated

func LocalIP() string

Deprecated: 使用 github.com/ixugo/netpulse/ip 替代 ip.InternalIP()

func PortUsed

func PortUsed(mode string, port int) bool

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

func RemoveEmptyDirs

func RemoveEmptyDirs(ctx context.Context, rootDir string, start, end time.Time) error

RemoveEmptyDirs 删除空目录,性能优化版,增加时间范围过滤

func TCPPortUsed added in v1.8.3

func TCPPortUsed(port int) bool

TCPPortUsed 通过尝试监听指定 TCP 端口来检测其是否已被占用

func UDPPortUsed added in v1.8.3

func UDPPortUsed(port int) bool

UDPPortUsed 通过尝试监听指定 UDP 端口来检测其是否已被占用

func WarnPrintf

func WarnPrintf(format string, a ...any)

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

type FileInfo struct {
	os.FileInfo
	Path string
}

func GlobFiles

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

GlobFiles 按照升序排列所有文件

Jump to

Keyboard shortcuts

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