utils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPortsToFirewall added in v0.4.7

func AddPortsToFirewall(ports []int)

func ExtractIP added in v0.3.7

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

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

func FilterNotEmpty added in v0.5.2

func FilterNotEmpty(item string) bool

func FormatAddress

func FormatAddress(addr string) string

FormatAddress format address

func IP2Long

func IP2Long(ip string) uint64

IP2Long 将IP转换为整型

func IsIPv4 added in v0.0.10

func IsIPv4(ip string) bool

IsIPv4 判断是否为IPv4

func IsIPv6 added in v0.0.10

func IsIPv6(ip string) bool

IsIPv6 判断是否为IPv6

func IsLocalIP added in v0.4.8

func IsLocalIP(ip net.IP) bool

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

func JSONClone added in v0.4.5

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

JSONClone 使用JSON克隆对象

func LookupCNAME

func LookupCNAME(host string) (string, error)

LookupCNAME 获取CNAME

func MapAddPrefixFunc added in v0.5.2

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

func NextIP added in v0.3.7

func NextIP(prevIP net.IP) net.IP

NextIP IP增加1

func PrintError

func PrintError(err error)

func RangeTimes added in v0.5.8

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 added in v0.5.3

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 added in v0.5.2

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

func NewStringsStream added in v0.5.2

func NewStringsStream(s []string) *StringsStream

func (*StringsStream) Filter added in v0.5.2

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

func (*StringsStream) Map added in v0.5.2

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

func (*StringsStream) Result added in v0.5.2

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

func (*StringsStream) Unique added in v0.5.2

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 UpgradeFileWriter added in v0.5.3

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

func NewUpgradeFileWriter added in v0.5.3

func NewUpgradeFileWriter(rawWriter io.Writer) *UpgradeFileWriter

func (*UpgradeFileWriter) TotalWritten added in v0.5.3

func (this *UpgradeFileWriter) TotalWritten() int64

func (*UpgradeFileWriter) Write added in v0.5.3

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

type UpgradeManager added in v0.5.3

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

func NewUpgradeManager added in v0.5.3

func NewUpgradeManager(component string) *UpgradeManager

func (*UpgradeManager) Cancel added in v0.5.3

func (this *UpgradeManager) Cancel() error

func (*UpgradeManager) IsDownloading added in v0.5.3

func (this *UpgradeManager) IsDownloading() bool

func (*UpgradeManager) NewVersion added in v0.5.3

func (this *UpgradeManager) NewVersion() string

func (*UpgradeManager) Progress added in v0.5.3

func (this *UpgradeManager) Progress() float32

func (*UpgradeManager) Start added in v0.5.3

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