utils

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPortsToFirewall

func AddPortsToFirewall(ports []int)

func ContainsStringInsensitive

func ContainsStringInsensitive(list []string, search string) bool

ContainsStringInsensitive 检查是否包含某个字符串,并且不区分大小写

func DumpResponse

func DumpResponse(resp *http.Response) (header []byte, body []byte, err error)

DumpResponse 导出响应

func IP2Long

func IP2Long(ip string) uint64

IP2Long 将IP转换为整型 注意IPv6没有顺序

func IsIPv6

func IsIPv6(ip string) bool

IsIPv6 判断是否为IPv6

func NewHTTPClient

func NewHTTPClient(timeout time.Duration) *http.Client

NewHTTPClient 获取一个新的Client

func ParseDomainFromKey

func ParseDomainFromKey(key string) (domain string)

ParseDomainFromKey 从Key中获取域名

func PrintError

func PrintError(err error)

打印错误

func RangeDays

func RangeDays(dayFrom string, dayTo string) ([]string, error)

RangeDays 计算日期之间的所有日期,格式为YYYYMMDD

func RangeHours

func RangeHours(hourFrom string, hourTo string) ([]string, error)

RangeHours 计算小时之间的所有小时,格式为YYYYMMDDHH

func RangeMonths

func RangeMonths(dayFrom string, dayTo string) ([]string, error)

RangeMonths 计算日期之间的所有月份,格式为YYYYMM

func SetRLimit

func SetRLimit(limit uint64) error

set resource limit

func SetSuitableRLimit

func SetSuitableRLimit()

set best resource limit value

func SharedHttpClient

func SharedHttpClient(timeout time.Duration) *http.Client

SharedHttpClient 获取一个公用的Client

func SplitStrings

func SplitStrings(s string, glue string) []string

SplitStrings 分隔字符串 忽略其中为空的片段

func VersionToLong

func VersionToLong(version string) uint32

计算版本代号

Types

type CacheMap

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

func NewCacheMap

func NewCacheMap() *CacheMap

func (*CacheMap) Get

func (this *CacheMap) Get(key string) (value interface{}, ok bool)

func (*CacheMap) Len

func (this *CacheMap) Len() int

func (*CacheMap) Put

func (this *CacheMap) Put(key string, value interface{})

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) Execute

func (this *ServiceManager) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32)

同服务管理器的交互

func (*ServiceManager) Install

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

安装服务

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) Run

func (this *ServiceManager) Run()

运行

func (*ServiceManager) Start

func (this *ServiceManager) Start() error

启动服务

func (*ServiceManager) Uninstall

func (this *ServiceManager) Uninstall() error

删除服务

type Ticker

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

func NewTicker

func NewTicker(duration time.Duration) *Ticker

func (*Ticker) Stop

func (this *Ticker) Stop()

func (*Ticker) Wait

func (this *Ticker) Wait() bool

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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