E

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

核心支持库工具函数库 增强核心支持库的功能

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Env

func Env(环境变量名称 string, 默认值 string) string

带有默认值的env读取函数 E读环境变量 一样效果

func E创建目录多级

func E创建目录多级(欲创建的目录名称 string) error

func E判断文本

func E判断文本(内容 string, 关键字 ...interface{}) bool

子程序名:判断文本 真 找到 假 找不到 返回值类型:逻辑型 参数<1>的名称为“与判断的文本”,类型为“文本型”。 参数<2>的名称为“关键字”,类型为“文本型”,允许接收空参数数据。 参数<3>的名称为“更多关键字”,类型为“文本型”,允许接收空参数数据,需要接收数组数据。

func E判断文本s

func E判断文本s(内容 string, 关键字 ...interface{}) string

func E判断文本前缀

func E判断文本前缀(s string, 前缀 string) bool

func E判断文本后缀

func E判断文本后缀(s string, 后缀 string) bool

func E到Json

func E到Json(v interface{}) string

func E加载环境变量_从内容到map

func E加载环境变量_从内容到map(s string) (map[string]string, error)

func E加载环境变量_从文件

func E加载环境变量_从文件(filepath string) bool

env

func E取md5

func E取md5(data []byte) string

func E取md5从文本

func E取md5从文本(str string) string

func E取uuid

func E取uuid() string

生成uuid

func E取文本字数

func E取文本字数(value string) int

func E取短id

func E取短id() string

生成短id

func E取随机ip

func E取随机ip() string

func E命令行解析

func E命令行解析()

func E文件_保存

func E文件_保存(文件名 string, 欲写入文件的数据 interface{}) error

自动检查内容是否一致是否需要写出

func E文件_写出

func E文件_写出(文件名 string, 欲写入文件的数据 interface{}) error

路径不存在时自动创建

func E文件_删除

func E文件_删除(欲删除的文件名 string) bool

func E文件_取扩展名

func E文件_取扩展名(filepath string) string

func E文件_取文件名

func E文件_取文件名(路径 string) string

func E文件_取父目录

func E文件_取父目录(dirpath string) string

func E文件_更名

func E文件_更名(欲更名的原文件或目录名 string, 欲更改为的现文件或目录名 string) bool

func E文件_枚举

func E文件_枚举(欲寻找的目录 string, 欲寻找的文件名 string, files *[]string, 是否带路径 bool, 是否遍历子目录 bool) error

子程序名:文件_枚举 枚举某个目录下的指定类型文件;成功返回文件数量; 返回值类型:整数型 参数<1>的名称为“欲寻找的目录”,类型为“文本型”。注明:文件目录。 参数<2>的名称为“欲寻找的文件名”,类型为“文本型”。注明:如果寻找全部文件可以填入空白,.txt|.jpg找txt和jpg的文件 参数<3>的名称为“文件数组”,类型为“文本型”,接收参数数据时采用参考传递方式,允许接收空参数数据,需要接收数组数据。注明:用于装载文件数组的变量;把寻找到的文件都放在这个数组里,并返回;。 参数<4>的名称为“是否带路径”,类型为“逻辑型”,允许接收空参数数据。注明:默认为假; 真=带目录路径,如C:\012.txt; 假=不带,如 012.txt;。 参数<6>的名称为“是否遍历子目录”,类型为“逻辑型”,允许接收空参数数据。注明:留空默认为假;为真时文件数组不主动清空。

func E文件_路径合并处理

func E文件_路径合并处理(elem ...string) string

func E文件_追加文本

func E文件_追加文本(文件名 string, 欲追加的文本 string) error

路径不存在时自动创建

func E文本_删中间

func E文本_删中间(欲处理文本 string, 起始位置 int64, 删除长度 int64) string

func E文本_删右边

func E文本_删右边(欲处理文本 string, 删除长度 int64) string

func E文本_删左边

func E文本_删左边(欲处理文本 string, 删除长度 int64) string

func E文本_单词首字母大写

func E文本_单词首字母大写(s string) string

func E文本_取出中间文本

func E文本_取出中间文本(内容 string, 左边文本 string, 右边文本 string) string

文本取出中间文本

func E文本_取出文本中汉字

func E文本_取出文本中汉字(s string) string

func E文本_取右边

func E文本_取右边(被查找的文本 string, 欲寻找的文本 string) string

func E文本_取左边

func E文本_取左边(被查找的文本 string, 欲寻找的文本 string) string

func E文本_取随机姓氏

func E文本_取随机姓氏() string

func E文本_取随机字母

func E文本_取随机字母(要取的字符数 int, 字母类型 int) string

子程序名:文本_取随机字母 取随机26个字母! 返回值类型:文本型 参数<1>的名称为“要取的字符数”,类型为“整数型”。注明:要取字符个数;。 参数<2>的名称为“字母类型”,类型为“整数型”,允许接收空参数数据。注明:可空:默认为小写字母;0=小写字母;1=大写字母;2=大小写字母混合;。

func E文本_取随机字母和数字

func E文本_取随机字母和数字(要取的字符数 int) string

func E文本_取随机数字

func E文本_取随机数字(要取的字符数 int) string

func E文本_句子首字母大写

func E文本_句子首字母大写(s string) string

func E文本_搜索切片文本

func E文本_搜索切片文本(a []string, s string) int

func E文本_是否为大写字母

func E文本_是否为大写字母(s string) bool

func E文本_是否为字母

func E文本_是否为字母(s string) bool

func E文本_是否为小写字母

func E文本_是否为小写字母(s string) bool

func E文本_是否为数字

func E文本_是否为数字(s string) bool

func E文本_是否为汉字

func E文本_是否为汉字(s string) bool

func E文本_相似文本

func E文本_相似文本(first, second string, percent *float64) int

SimilarText计算两个字符串之间的相似度。参见http://php.net/manual/en/function.similar-text.php。

func E文本_自动换行

func E文本_自动换行(s string, 每行几个字符 int, 分隔符 string) string

func E文本_自动补零

func E文本_自动补零(s string, len int) string

func E文本_逐字分割

func E文本_逐字分割(s string) []string

func E文本_随机文本

func E文本_随机文本(s string) string

func E文本_颠倒

func E文本_颠倒(s string) string

func E文本_首字母改大写

func E文本_首字母改大写(s string) string

func E文本区分_只取字母

func E文本区分_只取字母(s string) string

func E文本区分_只取数字

func E文本区分_只取数字(s string) string

func E文本区分_只取汉子

func E文本区分_只取汉子(s string) string

func E文本区分_只取符号

func E文本区分_只取符号(s string) string

func E格式化文本

func E格式化文本(format string, a ...interface{}) string

func E目录_枚举子目录

func E目录_枚举子目录(父文件夹路径 string, 子目录数组 *[]string, 是否带路径 bool, 是否继续向下枚举 bool) error

func E计算数学表达式

func E计算数学表达式(v string) string

子程序名:计算数学表达式 返回值类型:双精度小数型 参数<1>的名称为“数学表达式”,类型为“文本型”。

func E设置命令行

func E设置命令行(name string, defaultvalue string, help string, value *string)

func E读入文本

func E读入文本(文件名 string) string

从路径中读入文件的文本内容

func E路径_创建多级目录

func E路径_创建多级目录(要创建的目录 string) bool

调用格式: 〈逻辑型〉 路径_创建多级目录 (文本型 要创建的目录) - E2EE互联网服务器套件2.2.3->路径处理 英文名称:PathMakeAnyDir 创建任意级别的目录。目录存在直接返回真,不存在创建成功也返回真,创建失败返回假。本命令为初级命令。 参数<1>的名称为“要创建的目录”,类型为“文本型(text)”。要创建的目录路径。

操作系统需求: Windows

func E路径_合并

func E路径_合并(elem ...string) string

调用格式: 〈文本型〉 路径_合并 (文本型 路径1,文本型 路径2,... ) - E2EE互联网服务器套件2.2.3->路径处理 英文名称:PathJoin 合并多个路径。假设第一个路径为目录,路径之间将通过“/”连接。两个路径均支持相对路径符号“./”和“../”。路径不区分“\”和“/”,最终生成的路径都以“/”为主。本命令为初级命令。命令参数表中最后一个参数可以被重复添加。 参数<1>的名称为“路径1”,类型为“文本型(text)”。第一个路径。可以为相对路径。 参数<2>的名称为“路径2”,类型为“文本型(text)”。第二个路径。可以为相对路径。

操作系统需求: Windows

func Json解析

func Json解析(data string, path string) gjson.Result

func Json解析文本

func Json解析文本(data string, path string) string

简化用法

func RunJs

func RunJs(content string, functionName string, args ...interface{}) string

func StrCut

func StrCut(内容 string, 表达式 string) string

文本截取函数

Types

type E时间统计类

type E时间统计类 struct {
	// contains filtered or unexported fields
}

func New时间统计类

func New时间统计类() *E时间统计类

func (*E时间统计类) E取毫秒

func (this *E时间统计类) E取毫秒() string

func (*E时间统计类) E取秒

func (this *E时间统计类) E取秒() string

func (*E时间统计类) E开始

func (this *E时间统计类) E开始()

type E正则表达式

type E正则表达式 struct {

	//批量数量
	Count int
	//子匹配数量
	SubmatchCount2 int
	// contains filtered or unexported fields
}

func New正则表达式

func New正则表达式(正则表达式文本 string, 被搜索的文本 string) (*E正则表达式, bool)

func (*E正则表达式) E创建

func (this *E正则表达式) E创建(正则表达式文本 string, 被搜索的文本 string) bool

func (*E正则表达式) E取匹配数量

func (this *E正则表达式) E取匹配数量() int

func (*E正则表达式) E取匹配文本

func (this *E正则表达式) E取匹配文本(匹配索引 int) string

func (*E正则表达式) E取子匹配数量

func (this *E正则表达式) E取子匹配数量() int

func (*E正则表达式) E取子匹配文本

func (this *E正则表达式) E取子匹配文本(匹配索引 int, 子表达式索引 int) string

func (*E正则表达式) E替换

func (this *E正则表达式) E替换(用作替换的文本 string) string

func (*E正则表达式) GetResult

func (this *E正则表达式) GetResult() [][]string

type E线程池

type E线程池 struct {
	// contains filtered or unexported fields
}

func New线程池

func New线程池(最大任务数量 int) *E线程池

func (*E线程池) E初始化

func (this *E线程池) E初始化(最大任务数量 int)

func (*E线程池) E加入任务

func (this *E线程池) E加入任务()

func (*E线程池) E完成

func (this *E线程池) E完成()

func (*E线程池) E等待任务完成

func (this *E线程池) E等待任务完成()

type E读写共享锁

type E读写共享锁 struct {
	// contains filtered or unexported fields
}

func (*E读写共享锁) E开始写

func (this *E读写共享锁) E开始写()

func (*E读写共享锁) E开始读

func (this *E读写共享锁) E开始读()

func (*E读写共享锁) E结束写

func (this *E读写共享锁) E结束写()

func (*E读写共享锁) E结束读

func (this *E读写共享锁) E结束读()

type E配置项

type E配置项 struct {
	// contains filtered or unexported fields
}

func New配置项

func New配置项(配置项数据 string, 是否区分大小写 bool) *E配置项

func (*E配置项) E写到文件

func (this *E配置项) E写到文件(fileapth string)

func (*E配置项) E写配置项

func (this *E配置项) E写配置项(节名称 string, 配置项名称 string, 设置文本 string) bool

func (*E配置项) E加载配置项从内存

func (this *E配置项) E加载配置项从内存(v string) bool

func (*E配置项) E加载配置项从文件

func (this *E配置项) E加载配置项从文件(fileapth string) bool

InsensitiveLoad

func (*E配置项) E取节名

func (this *E配置项) E取节名() []string

func (*E配置项) E取项名

func (this *E配置项) E取项名(节名称 string) []string

func (*E配置项) E设置节名不区分大小写

func (this *E配置项) E设置节名不区分大小写()

func (*E配置项) E读配置项

func (this *E配置项) E读配置项(节名称 string, 配置项名称 string, 默认文本 string) string

type StrArray

type StrArray struct {
	Array []string
	// contains filtered or unexported fields
}

func NewStrArray

func NewStrArray(safe ...bool) *StrArray

NewStrArray creates and returns an empty Array. The parameter <safe> is used to specify whether using Array in concurrent-safety, which is false in default.

func NewStrArrayFrom

func NewStrArrayFrom(Array []string, safe ...bool) *StrArray

NewStrArrayFrom creates and returns an Array with given slice <Array>. The parameter <safe> is used to specify whether using Array in concurrent-safety, which is false in default.

func NewStrArrayFromCopy

func NewStrArrayFromCopy(Array []string, safe ...bool) *StrArray

NewStrArrayFromCopy creates and returns an Array from a copy of given slice <Array>. The parameter <safe> is used to specify whether using Array in concurrent-safety, which is false in default.

func NewStrArraySize

func NewStrArraySize(size int, cap int, safe ...bool) *StrArray

NewStrArraySize create and returns an Array with given size and cap. The parameter <safe> is used to specify whether using Array in concurrent-safety, which is false in default.

func New文本型数组

func New文本型数组() *StrArray

func (*StrArray) Append

func (a *StrArray) Append(value ...string) *StrArray

See PushRight.

func (*StrArray) Chunk

func (a *StrArray) Chunk(size int) [][]string

Chunk splits an Array into multiple Arrays, the size of each Array is determined by <size>. The last chunk may contain less than size elements.

func (*StrArray) Clear

func (a *StrArray) Clear() *StrArray

Clear deletes all items of current Array.

func (*StrArray) Clone

func (a *StrArray) Clone() (newArray *StrArray)

Clone returns a new Array, which is a copy of current Array.

func (*StrArray) Contains

func (a *StrArray) Contains(value string) bool

Contains checks whether a value exists in the Array.

func (*StrArray) CountValues

func (a *StrArray) CountValues() map[string]int

CountValues counts the number of occurrences of all values in the Array.

func (*StrArray) E删除成员

func (a *StrArray) E删除成员(欲删除的位置 int)

func (*StrArray) E加入成员

func (a *StrArray) E加入成员(s string)

func (*StrArray) E取

func (a *StrArray) E取(i int) string

func (*StrArray) E取数组成员数

func (a *StrArray) E取数组成员数() int

func (*StrArray) E插入成员

func (a *StrArray) E插入成员(欲插入的位置 int, 欲插入的成员数据 string)

func (*StrArray) E数组排序

func (a *StrArray) E数组排序(排序方向是否为从小到大 bool)

调用格式: 〈无返回值〉 数组排序 (通用型变量数组 数值数组变量,[逻辑型 排序方向是否为从小到大]) - 系统核心支持库->数组操作 英文名称:SortAry 对指定数值数组变量内的所有数组成员进行快速排序,不影响数组的维定义信息,排序结果存放回该数组变量。本命令为初级命令。 参数<1>的名称为“数值数组变量”,类型为“通用型(all)”,提供参数数据时只能提供变量数组。 参数<2>的名称为“排序方向是否为从小到大”,类型为“逻辑型(bool)”,可以被省略。如果参数值为真,排序方向为从小到大,否则为从大到小。如果本参数被省略,默认值为真。

操作系统需求: Windows、Linux

func (*StrArray) E清除数组

func (a *StrArray) E清除数组()

func (*StrArray) Fill

func (a *StrArray) Fill(startIndex int, num int, value string) *StrArray

Fill fills an Array with num entries of the value <value>, keys starting at the <startIndex> parameter.

func (*StrArray) Get

func (a *StrArray) Get(index int) string

Get returns the value of the specified index, the caller should notice the boundary of the Array.

func (*StrArray) InsertAfter

func (a *StrArray) InsertAfter(index int, value string) *StrArray

InsertAfter inserts the <value> to the back of <index>.

func (*StrArray) InsertBefore

func (a *StrArray) InsertBefore(index int, value string) *StrArray

InsertBefore inserts the <value> to the front of <index>.

func (*StrArray) Interfaces

func (a *StrArray) Interfaces() []interface{}

Interfaces returns current Array as []interface{}.

func (*StrArray) Iterator

func (a *StrArray) Iterator(f func(k int, v string) bool)

Iterator is alias of IteratorAsc.

func (*StrArray) IteratorAsc

func (a *StrArray) IteratorAsc(f func(k int, v string) bool)

IteratorAsc iterates the Array in ascending order with given callback function <f>. If <f> returns true, then it continues iterating; or false to stop.

func (*StrArray) IteratorDesc

func (a *StrArray) IteratorDesc(f func(k int, v string) bool)

IteratorDesc iterates the Array in descending order with given callback function <f>. If <f> returns true, then it continues iterating; or false to stop.

func (*StrArray) Join

func (a *StrArray) Join(glue string) string

Join joins Array elements with a string <glue>.

func (*StrArray) Len

func (a *StrArray) Len() int

Len returns the length of Array.

func (*StrArray) LockFunc

func (a *StrArray) LockFunc(f func(Array []string)) *StrArray

LockFunc locks writing by callback function <f>.

func (*StrArray) MarshalJSON

func (a *StrArray) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*StrArray) Pad

func (a *StrArray) Pad(size int, value string) *StrArray

Pad pads Array to the specified length with <value>. If size is positive then the Array is padded on the right, or negative on the left. If the absolute value of <size> is less than or equal to the length of the Array then no padding takes place.

func (*StrArray) PopLeft

func (a *StrArray) PopLeft() string

PopLeft pops and returns an item from the beginning of Array.

func (*StrArray) PopLefts

func (a *StrArray) PopLefts(size int) []string

PopLefts pops and returns <size> items from the beginning of Array.

func (*StrArray) PopRand

func (a *StrArray) PopRand() string

PopRand randomly pops and return an item out of Array.

func (*StrArray) PopRands

func (a *StrArray) PopRands(size int) []string

PopRands randomly pops and returns <size> items out of Array.

func (*StrArray) PopRight

func (a *StrArray) PopRight() string

PopRight pops and returns an item from the end of Array.

func (*StrArray) PopRights

func (a *StrArray) PopRights(size int) []string

PopRights pops and returns <size> items from the end of Array.

func (*StrArray) PushLeft

func (a *StrArray) PushLeft(value ...string) *StrArray

PushLeft pushes one or multiple items to the beginning of Array.

func (*StrArray) PushRight

func (a *StrArray) PushRight(value ...string) *StrArray

PushRight pushes one or multiple items to the end of Array. It equals to Append.

func (*StrArray) RLockFunc

func (a *StrArray) RLockFunc(f func(Array []string)) *StrArray

RLockFunc locks reading by callback function <f>.

func (*StrArray) Rand

func (a *StrArray) Rand() string

Rand randomly returns one item from Array(no deleting).

func (*StrArray) Rands

func (a *StrArray) Rands(size int) []string

Rands randomly returns <size> items from Array(no deleting).

func (*StrArray) Range

func (a *StrArray) Range(start int, end ...int) []string

Range picks and returns items by range, like Array[start:end]. Notice, if in concurrent-safe usage, it returns a copy of slice; else a pointer to the underlying data.

If <end> is negative, then the offset will start from the end of Array. If <end> is omitted, then the sequence will have everything from start up until the end of the Array.

func (*StrArray) Remove

func (a *StrArray) Remove(index int) string

Remove removes an item by index.

func (*StrArray) RemoveValue

func (a *StrArray) RemoveValue(value string) bool

RemoveValue removes an item by value. It returns true if value is found in the Array, or else false if not found.

func (*StrArray) Replace

func (a *StrArray) Replace(Array []string) *StrArray

Replace replaces the Array items by given <Array> from the beginning of Array.

func (*StrArray) Reverse

func (a *StrArray) Reverse() *StrArray

Reverse makes Array with elements in reverse order.

func (*StrArray) Search

func (a *StrArray) Search(value string) int

Search searches Array by <value>, returns the index of <value>, or returns -1 if not exists.

func (*StrArray) Set

func (a *StrArray) Set(index int, value string) *StrArray

Set sets value to specified index.

func (*StrArray) SetArray

func (a *StrArray) SetArray(Array []string) *StrArray

SetArray sets the underlying slice Array with the given <Array>.

func (*StrArray) Shuffle

func (a *StrArray) Shuffle() *StrArray

Shuffle randomly shuffles the Array.

func (*StrArray) Slice

func (a *StrArray) Slice() []string

Slice returns the underlying data of Array. Note that, if it's in concurrent-safe usage, it returns a copy of underlying data, or else a pointer to the underlying data.

func (*StrArray) Sort

func (a *StrArray) Sort(reverse ...bool) *StrArray

Sort sorts the Array in increasing order. The parameter <reverse> controls whether sort in increasing order(default) or decreasing order

func (*StrArray) SortFunc

func (a *StrArray) SortFunc(less func(v1, v2 string) bool) *StrArray

SortFunc sorts the Array by custom function <less>.

func (*StrArray) String

func (a *StrArray) String() string

String returns current Array as a string, which implements like json.Marshal does.

func (*StrArray) SubSlice

func (a *StrArray) SubSlice(offset int, length ...int) []string

SubSlice returns a slice of elements from the Array as specified by the <offset> and <size> parameters. If in concurrent safe usage, it returns a copy of the slice; else a pointer.

If offset is non-negative, the sequence will start at that offset in the Array. If offset is negative, the sequence will start that far from the end of the Array.

If length is given and is positive, then the sequence will have up to that many elements in it. If the Array is shorter than the length, then only the available Array elements will be present. If length is given and is negative then the sequence will stop that many elements from the end of the Array. If it is omitted, then the sequence will have everything from offset up until the end of the Array.

Any possibility crossing the left border of Array, it will fail.

func (*StrArray) Sum

func (a *StrArray) Sum() (sum int)

Sum returns the sum of values in an Array.

func (*StrArray) Unique

func (a *StrArray) Unique() *StrArray

Unique uniques the Array, clear repeated items.

func (*StrArray) UnmarshalJSON

func (a *StrArray) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*StrArray) UnmarshalValue

func (a *StrArray) UnmarshalValue(value interface{}) error

UnmarshalValue is an interface implement which sets any type of value for Array.

Jump to

Keyboard shortcuts

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