teautils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT, MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllCharsets = []maps.Map{}/* 122 elements not displayed */
View Source
var BasicCharsets = []maps.Map{
	{"name": "Chinese Traditional (Big5)", "charset": "big5"},
	{"charset": "euc-kr", "name": "Korean (EUC)"},
	{"charset": "iso-8859-1", "name": "Western Alphabet"},
	{"charset": "iso-8859-2", "name": "Central European Alphabet (ISO)"},
	{"charset": "iso-8859-3", "name": "Latin 3 Alphabet (ISO)"},
	{"charset": "iso-8859-4", "name": "Baltic Alphabet (ISO)"},
	{"charset": "iso-8859-5", "name": "Cyrillic Alphabet (ISO)"},
	{"charset": "iso-8859-6", "name": "Arabic Alphabet (ISO)"},
	{"charset": "iso-8859-7", "name": "Greek Alphabet (ISO)"},
	{"charset": "iso-8859-8", "name": "Hebrew Alphabet (ISO)"},
	{"charset": "koi8-r", "name": "Cyrillic Alphabet (KOI8-R)"},
	{"charset": "shift-jis", "name": "Japanese (Shift-JIS)"},
	{"name": "Japanese (EUC)", "charset": "x-euc"},
	{"charset": "utf-8", "name": "Universal Alphabet (UTF-8)"},
	{"charset": "windows-1250", "name": "Central European Alphabet (Windows)"},
	{"charset": "windows-1251", "name": "Cyrillic Alphabet (Windows)"},
	{"charset": "windows-1252", "name": "Western Alphabet (Windows)"},
	{"charset": "windows-1253", "name": "Greek Alphabet (Windows)"},
	{"charset": "windows-1254", "name": "Turkish Alphabet"},
	{"charset": "windows-1255", "name": "Hebrew Alphabet (Windows)"},
	{"charset": "windows-1256", "name": "Arabic Alphabet (Windows)"},
	{"charset": "windows-1257", "name": "Baltic Alphabet (Windows)"},
	{"charset": "windows-1258", "name": "Vietnamese Alphabet (Windows)"},
	{"charset": "windows-874", "name": "Thai (Windows)"},
}

数据来自 https://webcheatsheet.com/html/character_sets_list.php

View Source
var RegexpDigitNumber = regexp.MustCompile("^\\d+$")
View Source
var UsualCharsets = []maps.Map{
	{"charset": "utf-8", "name": "Universal Alphabet (UTF-8)"},
	{"charset": "unicode", "name": "Unicode"},
	{"name": "Chinese Simplified (GB2312)", "charset": "gb2312"},
	{"charset": "big5", "name": "Chinese Traditional (Big5)"},
	{"charset": "iso-8859-1", "name": "Western Alphabet"},
	{"charset": "euc-kr", "name": "Korean (EUC)"},
	{"charset": "shift-jis", "name": "Japanese (Shift-JIS)"},
	{"charset": "us-ascii", "name": "US-ASCII"},
}

Functions

func CheckPid

func CheckPid(path string) *os.Process

检查Pid

func CloseHTTPClient

func CloseHTTPClient(client *http.Client)

关闭客户端连接

func ConvertJSONObjectSafely

func ConvertJSONObjectSafely(obj interface{}) interface{}

去除导致不能转换特殊内容的问题 当前不支持struct

func CopyStructObject

func CopyStructObject(destPtr, sourcePtr interface{})

拷贝同类型struct指针对象中的字段

func DeletePid

func DeletePid(path string) error

删除Pid

func DumpResponse

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

导出响应

func FormatAddress

func FormatAddress(addr string) string

format address

func FormatAddressList

func FormatAddressList(addrList []string) []string

format address list

func Get

func Get(object interface{}, keys []string) interface{}

func ListenSignal

func ListenSignal(f func(sig os.Signal), sig ...os.Signal)

监听Signal

func LockFile

func LockFile(fp *os.File) error

lock file

func MapKeys

func MapKeys(s maps.Map) (keys []string)

获取所有的键值

func MapToObjectJSON

func MapToObjectJSON(fromMap map[string]interface{}, toPtr interface{}) error

通过JSON把map转换为object

func MapToObjectYAML

func MapToObjectYAML(fromMap map[string]interface{}, toPtr interface{}) error

通过YAML把map转换为object

func MatchDomains

func MatchDomains(patterns []string, domain string) (isMatched bool)

从一组规则中匹配域名 支持的格式:example.com, www.example.com, .example.com, *.example.com, ~(\d+).example.com 更多参考:http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name

func MatchKeyword

func MatchKeyword(source, keyword string) bool

关键词匹配

func NewHTTPClient

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

获取一个新的Client

func NotifySignal

func NotifySignal(proc *os.Process, sig os.Signal) error

通知Signal

func ObjectToMapJSON

func ObjectToMapJSON(fromPtr interface{}, toMap *map[string]interface{}) error

通过JSON把object转换为map

func ParseVariables

func ParseVariables(source string, replacer func(varName string) (value string)) string

分析变量

func Recover

func Recover()

记录panic日志

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

获取一个公用的Client

func TmpFile

func TmpFile(path string) string

临时文件

func UnlockFile

func UnlockFile(fp *os.File) error

func UnsafeBytesToString

func UnsafeBytesToString(bs []byte) string

convert bytes to string

func UnsafeStringToBytes

func UnsafeStringToBytes(s string) []byte

convert string to bytes

func WebRoot

func WebRoot() string

Web根目录

func WritePid

func WritePid(path string) error

写入Pid

func WritePpid

func WritePpid(path string) error

写入Ppid

Types

type BytePool

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

pool for get byte slice

func NewBytePool

func NewBytePool(maxSize, length int) *BytePool

创建新对象

func (*BytePool) Destroy

func (this *BytePool) Destroy()

销毁

func (*BytePool) Get

func (this *BytePool) Get() (b []byte)

获取一个新的byte slice

func (*BytePool) Put

func (this *BytePool) Put(b []byte)

放回一个使用过的byte slice

func (*BytePool) Size

func (this *BytePool) Size() int

当前的数量

type Command

type Command struct {
	Name string
	Args []string
}

命令定义

type CommandExecutor

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

命令执行器

func NewCommandExecutor

func NewCommandExecutor() *CommandExecutor

获取新对象

func (*CommandExecutor) Add

func (this *CommandExecutor) Add(command string, arg ...string)

添加命令

func (*CommandExecutor) Run

func (this *CommandExecutor) Run() (output string, err error)

执行命令

type CommandHelp

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

命令帮助

func NewCommandHelp

func NewCommandHelp() *CommandHelp

func (*CommandHelp) Append

func (this *CommandHelp) Append(appendString string) *CommandHelp

附加内容

func (*CommandHelp) Option

func (this *CommandHelp) Option(code string, description string) *CommandHelp

选项

func (*CommandHelp) Print

func (this *CommandHelp) Print()

打印

func (*CommandHelp) Product

func (this *CommandHelp) Product(product string) *CommandHelp

产品

func (*CommandHelp) Usage

func (this *CommandHelp) Usage(usage string) *CommandHelp

使用方法

func (*CommandHelp) Version

func (this *CommandHelp) Version(version string) *CommandHelp

版本

type CommandHelpOption

type CommandHelpOption struct {
	Code        string
	Description string
}

type ObjectPool

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

对象池

func NewObjectPool

func NewObjectPool(maxSize int, newFunc func() interface{}) *ObjectPool

创建新对象

func (*ObjectPool) Destroy

func (this *ObjectPool) Destroy()

销毁

func (*ObjectPool) Get

func (this *ObjectPool) Get() (obj interface{})

获取一个新的对象

func (*ObjectPool) Put

func (this *ObjectPool) Put(obj interface{})

放回一个使用过的对象

func (*ObjectPool) Size

func (this *ObjectPool) Size() int

当前的数量

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 {
	S chan bool
	C <-chan time.Time
	// contains filtered or unexported fields
}

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

func Every

func Every(duration time.Duration, f func(ticker *Ticker)) *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 VariableHolder

type VariableHolder string

变量信息存储类型

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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