utils

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: BSD-3-Clause Imports: 35 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 GroupMinuteRanges added in v0.4.9

func GroupMinuteRanges(minutes []timeMinute) []timeMinuteRange

GroupMinuteRanges 将时间点分组

func IP2Long

func IP2Long(ip string) uint64

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

func IsIPv6

func IsIPv6(ip string) bool

IsIPv6 判断是否为IPv6

func LimitString added in v0.5.2

func LimitString(s string, maxLength int) string

LimitString 限制字符串长度

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

func RangeMinutes(toTime time.Time, count int, everyMinutes int64) []timeMinute

RangeMinutes 计算若干个时间点,返回结果为 [ [day1, minute1], [day2, minute2] ... ]

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

func Sha1RandomString() string

func SharedHttpClient

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

SharedHttpClient 获取一个公用的Client

func Similar added in v0.5.0

func Similar(s1 string, s2 string) float32

Similar 计算相似度 between 0-1

func SplitStrings

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

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

func SystemMemoryGB added in v0.4.9

func SystemMemoryGB() int

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