utils

package
v0.0.0-...-8f5e843 Latest Latest
Warning

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

Go to latest
Published: May 19, 2025 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPortsToFirewall

func AddPortsToFirewall(ports []int)

func ExtractIP

func ExtractIP(ipStrings string) ([]string, error)

ExtractIP 分解IP 只支持D段掩码的CIDR 最多只记录255个值

func FilterNotEmpty

func FilterNotEmpty(item string) bool

func FormatAddress

func FormatAddress(addr string) string

FormatAddress format address

func IsLocalIP

func IsLocalIP(ip net.IP) bool

IsLocalIP 判断是否为本地IP ip 是To4()或者To16()的结果

func JSONClone

func JSONClone(v interface{}) (interface{}, error)

JSONClone 使用JSON克隆对象

func JSONDecodeConfig

func JSONDecodeConfig(data []byte, ptr any) (encodeJSON []byte, err error)

JSONDecodeConfig 解码并重新编码 是为了去除原有JSON中不需要的数据

func JSONIsNull

func JSONIsNull(jsonData []byte) bool

JSONIsNull 判断JSON数据是否为null

func LookupCNAME

func LookupCNAME(host string) (string, error)

LookupCNAME 获取CNAME

func MapAddPrefixFunc

func MapAddPrefixFunc(prefix string) func(item string) string

func NextIP

func NextIP(prevIP net.IP) net.IP

NextIP IP增加1

func ParseIPValue

func ParseIPValue(value string) (newValue string, ipFrom string, ipTo string, ok bool)

ParseIPValue 解析IP值

func PrintError

func PrintError(err error)

func RangeTimes

func RangeTimes(timeFrom string, timeTo string, everyMinutes int32) (result []string, err error)

RangeTimes 计算时间点

func Recover

func Recover()

func SplitNumbers

func SplitNumbers(numbers string) (result []int64)

SplitNumbers 分割数字

func ValidateEmail

func ValidateEmail(email string) bool

ValidateEmail 校验电子邮箱格式

Types

type ServiceManager

type ServiceManager struct {
	Name        string
	Description string
	// contains filtered or unexported fields
}

服务管理器

func NewServiceManager

func NewServiceManager(name, description string) *ServiceManager

获取对象

func (*ServiceManager) Close

func (this *ServiceManager) Close() error

关闭

func (*ServiceManager) Install

func (this *ServiceManager) Install(exePath string, args []string) error

Install 安装服务

func (*ServiceManager) Log

func (this *ServiceManager) Log(msg string)

记录普通日志

func (*ServiceManager) LogError

func (this *ServiceManager) LogError(msg string)

记录错误日志

func (*ServiceManager) PauseWindow

func (this *ServiceManager) PauseWindow()

保持命令行窗口是打开的

func (*ServiceManager) Start

func (this *ServiceManager) Start() error

Start 启动服务

func (*ServiceManager) Uninstall

func (this *ServiceManager) Uninstall() error

Uninstall 删除服务

type StringsStream

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

func NewStringsStream

func NewStringsStream(s []string) *StringsStream

func (*StringsStream) Filter

func (this *StringsStream) Filter(f ...func(item string) bool) *StringsStream

func (*StringsStream) Map

func (this *StringsStream) Map(f ...func(item string) string) *StringsStream

func (*StringsStream) Result

func (this *StringsStream) Result() []string

func (*StringsStream) Unique

func (this *StringsStream) Unique() *StringsStream

type Ticker

type Ticker struct {
	S chan bool
	C <-chan time.Time
	// contains filtered or unexported fields
}

类似于time.Ticker,但能够真正地停止

func NewTicker

func NewTicker(duration time.Duration) *Ticker

创建新Ticker

func (*Ticker) Next

func (this *Ticker) Next() bool

查找下一个Tick

func (*Ticker) Stop

func (this *Ticker) Stop()

停止

type Unzip

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

func NewUnzip

func NewUnzip(zipFile string, targetDir string) *Unzip

func (*Unzip) Run

func (this *Unzip) Run() error

type UpgradeFileWriter

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

func NewUpgradeFileWriter

func NewUpgradeFileWriter(rawWriter io.Writer) *UpgradeFileWriter

func (*UpgradeFileWriter) TotalWritten

func (this *UpgradeFileWriter) TotalWritten() int64

func (*UpgradeFileWriter) Write

func (this *UpgradeFileWriter) Write(p []byte) (n int, err error)

type UpgradeManager

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

func NewUpgradeManager

func NewUpgradeManager(component string, downloadURL string) *UpgradeManager

func (*UpgradeManager) Cancel

func (this *UpgradeManager) Cancel() error

func (*UpgradeManager) IsDownloading

func (this *UpgradeManager) IsDownloading() bool

func (*UpgradeManager) NewVersion

func (this *UpgradeManager) NewVersion() string

func (*UpgradeManager) Progress

func (this *UpgradeManager) Progress() float32

func (*UpgradeManager) Start

func (this *UpgradeManager) Start() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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