utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareMcVersion

func CompareMcVersion(mainVersion, compareVersion string) int

比较mc版本 1表示大于,0表示等于,-1表示小于

func CompressFile

func CompressFile(source, destination string) error

压缩单个文件

func CompressFiles

func CompressFiles(sources []string, destination string) error

压缩多个文件, 相同则覆盖

func CopyDir

func CopyDir(src, dest string) error

复制文件夹对外暴露方法

func CreatDir

func CreatDir(dirPath string) error

递归创建文件夹

func CreateFile

func CreateFile(path string) (*os.File, error)

创建文件

func Ellipsis

func Ellipsis(str string, l int) string

字符串超出长度截断,加深略号

func ExistsResource

func ExistsResource(path string) bool

判断所给路径文件/文件夹是否存在

func FormateTable

func FormateTable(header []string, data [][]string) string

格式化数据为表格

func GBK2UTF8

func GBK2UTF8(data []byte) ([]byte, error)

GBK转UTF8

func GetCommandArr

func GetCommandArr(memory int64, runPath string) []string

获取cmd命令数组

func GetCurrentPath

func GetCurrentPath() (string, error)

获取当前执行文件目录

func GetFilesFromDir

func GetFilesFromDir(dirPath string) []string

获取指定目录下所有文件(去除目录)

func GetFreePort

func GetFreePort(port int64) (int64, error)

GetFreePort 获取系统空闲端口 如果port为0,则表示随机获取一个空闲端口,不为0则为指定端口

func IntToint32

func IntToint32(i int) int32

Int转int32

func IsDir

func IsDir(path string) bool

判断所给路径是否为文件夹

func IsFile

func IsFile(path string) bool

判断所给路径是否为文件

func IsUTF8

func IsUTF8(data []byte) bool

是否是UTF8编码

func Md5

func Md5(str string) string

md5加密

func NewConfParam

func NewConfParam(confKey, ConfVal, description string, level int64, IsAlterable bool) *models.ConfParam

创建confParam实例

func OpenBrowser

func OpenBrowser(url string)

打开浏览器

func PanicError

func PanicError(msg string, err error)

致命错误,退出程序

func ParseCharacter

func ParseCharacter(data []byte) ([]byte, error)

判断字符编码是否不是UTF8, 如果不是,尝试转成UTF8

func ParsePluginCommand

func ParsePluginCommand(msg string) (command string, params []string)

解析mc玩家发言插件命令

func RemoveRepeatedElement

func RemoveRepeatedElement(arr []string) []string

去除数组内相同的元素(set化)

func UTF82GBK

func UTF82GBK(data []byte) ([]byte, error)

UTF8转GBK

func Uint64Tofloat64

func Uint64Tofloat64(ui uint64) float64

Uint64转float64

func UnCompressDir

func UnCompressDir(source, destination string) error

解压到文件夹

Types

type Item added in v1.1.0

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

链表元素

type List added in v1.1.0

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

链表

func (*List) DelByCallback added in v1.1.0

func (l *List) DelByCallback(cb func(int, interface{}) bool)

func (*List) DelWithIndex added in v1.1.0

func (l *List) DelWithIndex(i int)

func (*List) GetLen added in v1.1.0

func (l *List) GetLen() int

func (*List) InsertWithIndex added in v1.1.0

func (l *List) InsertWithIndex(i int, value interface{})

func (*List) InsertWithIndexAndTypeName added in v1.1.0

func (l *List) InsertWithIndexAndTypeName(i int, value interface{}, typeName string)

func (*List) LPush added in v1.1.0

func (l *List) LPush(value interface{})

func (*List) LPushWithTypeName added in v1.1.0

func (l *List) LPushWithTypeName(value interface{}, typeName string)

func (*List) RPush added in v1.1.0

func (l *List) RPush(value interface{})

func (*List) RPushWithTypeName added in v1.1.0

func (l *List) RPushWithTypeName(value interface{}, typeName string)

func (*List) ToArray added in v1.1.0

func (l *List) ToArray() []interface{}

func (*List) ToJson added in v1.1.0

func (l *List) ToJson() (string, error)

type TellrowMessage

type TellrowMessage map[string]string

func NewTellrowMessage

func NewTellrowMessage() TellrowMessage

func (TellrowMessage) JSON

func (t TellrowMessage) JSON() string

func (TellrowMessage) SetParam

func (t TellrowMessage) SetParam(param, val string) TellrowMessage

func (TellrowMessage) SetText

func (t TellrowMessage) SetText(text string) TellrowMessage

func (TellrowMessage) SetTextColor

func (t TellrowMessage) SetTextColor(text, color string) TellrowMessage

Jump to

Keyboard shortcuts

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