Documentation ¶
Index ¶
- Constants
- func AbsInt(a int) int
- func AbsInt64(a int64) int64
- func AmountToCny(val string) string
- func Base62(bts []byte) string
- func Base62Decode(str string) ([]byte, error)
- func Base62Encode(bts []byte) string
- func Base64(bts []byte) string
- func Base64Decode(str string) ([]byte, error)
- func Base64Encode(bts []byte) string
- func BoolToString(b bool) string
- func BytesToReader(bts []byte) io.Reader
- func BytesToString(b []byte) string
- func BytesToUint32(bytes []byte) uint32
- func BytesToUint64(bytes []byte) uint64
- func CamelToUnderline(str string) string
- func Compress(srcBytes []byte) []byte
- func Contains(str string, substr string) bool
- func ContainsIngoreCase(str string, substr string) bool
- func ContainsItem(ary []string, str string, ingnoreCase ...bool) bool
- func ContentType(dotExt string, contentTypeMap map[string]string) string
- func CopyDir(srcDir, dstDir string) error
- func CopyFile(srcFilePath string, dstFilePath string) error
- func CreateBlankTempFile() string
- func Debug(v ...any)
- func DecodeRsa(str string, priKey string) (string, error)
- func DecodeRsaByPriFile(str string, pubKeyFileName string) (string, error)
- func DecodeRsaBytes(cipherText, privateKey []byte) ([]byte, error)
- func DecodeRsaBytesByPriFile(data []byte, privateKeyFileName string) ([]byte, error)
- func Dir(path string) string
- func EncodeRsa(str string, pubKey string) (string, error)
- func EncodeRsaByPubFile(str string, pubKeyFileName string) (string, error)
- func EncodeRsaBytes(data []byte, publicKey []byte) ([]byte, error)
- func EncodeRsaBytesByPubFile(data []byte, pubKeyFileName string) ([]byte, error)
- func Endwiths(str string, endstr string, ignoreCase ...bool) bool
- func EqualsIngoreCase(str1 string, str2 string) bool
- func Error(v ...any)
- func ExecCmd(command string) (stdout, stderr string, err error)
- func ExecTime(fn func()) int64
- func FasthttpPostJson(url string, jsondata string, headers ...string) ([]byte, error)
- func FileExtName(name string) string
- func FileName(name string) string
- func FileNameWithoutExt(name string) string
- func Float64ToCny(val float64) string
- func Float64ToInt64(f float64) int64
- func Float64ToString(num float64) string
- func Float64ToStringRoundDown(num float64, digit int32) string
- func FormatAmountRound(num float64, digit int32) string
- func FormatDate(date time.Time, fmt DateFormat) string
- func FormatRound(num float64, digit int32) string
- func FormatSystemDate(fmt DateFormat) string
- func GbkToUtf8(gbk []byte) []byte
- func GenerateRSAKey(keySize int) (privateKey []byte, publicKey []byte, err error)
- func GenerateRsaKey() error
- func GenerateRsaKeyFile(keySize int, priKeyFile, pubKeyFile string) error
- func GetCityByIp(ip string) string
- func GetCityIp(ip string) string
- func GetEnvBool(name string, defaultValue ...bool) bool
- func GetEnvInt(name string, defaultValue ...int) int
- func GetEnvStr(name string, defaultValue ...string) string
- func GetFasthttpClientIp(ctx *fasthttp.RequestCtx) string
- func GetFiles(dir string, suffix string) ([]string, error)
- func GetGlcLatestVersion(url string) string
- func GetHtmlText(strHtml string) string
- func GetLocalHostName() string
- func GetLocalIp() string
- func GetSizeInfo(size uint64) string
- func GetTimeInfo(milliseconds int64) string
- func GetYearMonthWeek() string
- func GetYyyymmdd(addDays int) string
- func Gzip(srcFile string, gzipFile string) error
- func GzipBytes(bts []byte) ([]byte, error)
- func Hash(str string) uint32
- func HashCode(bts []byte) uint32
- func HashMod(str string, mod uint32) uint32
- func HashString(str string) string
- func HexToRgb(hex string) (rgb []int)
- func HttpDownload(url, saveAsPathFile string, headers ...string) error
- func HttpGetJson(url string, headers ...string) ([]byte, error)
- func HttpPostForm(url string, formMap map[string]string, headers ...string) ([]byte, error)
- func HttpPostJson(url string, jsondata string, headers ...string) ([]byte, error)
- func HttpUploadFile(url string, filePath string, headers ...string) ([]byte, error)
- func IifStr(condtion bool, s1 string, s2 string) string
- func IncludesStr(slice []string, str string) bool
- func IncludesStrIgnoreCase(slice []string, str string) bool
- func IndexOf(str string, substr string) int
- func Info(v ...any)
- func Int64ToBytes(i int64) []byte
- func Int64ToString(i int64) string
- func IntToBytes(intNum int) []byte
- func IntToExcelColumn(iCol int) string
- func IntToString(i int) string
- func IsAlpha(s string) bool
- func IsAlphaDigit(s string) bool
- func IsAlpine() bool
- func IsBlank(str string) bool
- func IsDigit(s string) bool
- func IsEmail(str string) bool
- func IsExistDir(dir string) bool
- func IsExistFile(file string) bool
- func IsFullWidth(s string) bool
- func IsHalfWidth(s string) bool
- func IsIPv4(str string) bool
- func IsIPv6(str string) bool
- func IsIdCard(idCard string) bool
- func IsIp(str string) bool
- func IsLinux() bool
- func IsMac() bool
- func IsMobile(phone string) bool
- func IsNumber(s string) bool
- func IsPortOpening(port string) bool
- func IsServerPortOpening(ip string, port string) bool
- func IsTypeOfArray(v any) bool
- func IsTypeOfBool(v any) bool
- func IsTypeOfChan(v any) bool
- func IsTypeOfComplex128(v any) bool
- func IsTypeOfComplex64(v any) bool
- func IsTypeOfFloat32(v any) bool
- func IsTypeOfFloat64(v any) bool
- func IsTypeOfFunc(v any) bool
- func IsTypeOfInt(v any) bool
- func IsTypeOfInt16(v any) bool
- func IsTypeOfInt32(v any) bool
- func IsTypeOfInt64(v any) bool
- func IsTypeOfInt8(v any) bool
- func IsTypeOfInterface(v any) bool
- func IsTypeOfMap(v any) bool
- func IsTypeOfPointer(v any) bool
- func IsTypeOfSlice(v any) bool
- func IsTypeOfString(v any) bool
- func IsTypeOfStruct(v any) bool
- func IsTypeOfUint(v any) bool
- func IsTypeOfUint16(v any) bool
- func IsTypeOfUint32(v any) bool
- func IsTypeOfUint64(v any) bool
- func IsTypeOfUint8(v any) bool
- func IsTypeOfUintptr(v any) bool
- func IsTypeOfUnsafePointer(v any) bool
- func IsWin() bool
- func Join(elems []string, sep string) string
- func Lcs(s1 string, s2 string) string
- func Left(str string, length int) string
- func Len(str string) int
- func Md5(bts []byte) string
- func Md5File(pathfile string) string
- func MeasureCPU() (physicalCount int, logicalCount int, usePercent float64)
- func MeasureDisk() (total uint64, used uint64, free uint64, usePercent float64)
- func MeasureDiskByPath(path string) (total uint64, used uint64, free uint64, usePercent float64, err error)
- func MeasureDiskFreeSpace(path string) string
- func MeasureDisks() []*disk.UsageStat
- func MeasureHost() (*host.InfoStat, error)
- func MeasureMemory() (total uint64, used uint64, free uint64, usePercent float64)
- func MeasureSummary() (cpuUsedPercent float64, memUsedPercent float64, diskUsedPercent float64)
- func MeasureSwap() (total uint64, used uint64, free uint64, usePercent float64)
- func MkdirAll(dir string) error
- func NormalizeVer(ver string) string
- func Now() string
- func NowTime(fmt string) string
- func OfMap(kvs ...any) map[string]any
- func OnExit(fnExit func())
- func PadLeft(str string, pad string, length int) string
- func PadRight(str string, pad string, length int) string
- func ParseDate(date string, fmt DateFormat) (time.Time, error)
- func PathSeparator() string
- func RadomUint32() uint32
- func RandomHashString() string
- func RandomInt(min, max int) int
- func RandomString(length int) string
- func RandomUint32() uint32
- func RandomUint64() uint64
- func ReadFileBytes(filename string) ([]byte, error)
- func ReadFileString(filename string) (string, error)
- func ReaderToBytes(ioReader io.Reader) []byte
- func Recover()
- func RemoveAllFile(pathorfile string) error
- func Repeat(str string, count int) string
- func Replace(str string, old string, new string, n int) string
- func ReplaceAll(str string, old string, new string) string
- func ReplaceAllSpace(str string, new string) string
- func Retry(callback func() error, retryTimes int, duration time.Duration) (err error)
- func Reverse(str string) string
- func RgbToHex(r int, g int, b int) string
- func Right(str string, length int) string
- func Round(num float64, digit int32) float64
- func Round1(num float64) float64
- func Round2(num float64) float64
- func RoundDown(num float64, digit int32) float64
- func SetGlcClient(glcClient *GlcClient)
- func Split(str string, sep string) []string
- func SshCmd(host string, port string, user string, password string, cmd ...string) (string, error)
- func Startwiths(str string, startstr string, ignoreCase ...bool) bool
- func String2Float64(s string, defaultVal ...float64) float64
- func StringToBool(s string, defaultVal bool) bool
- func StringToBytes(s string) []byte
- func StringToInt(s string, defaultVal ...int) int
- func StringToInt64(s string, defaultVal ...int64) int64
- func StringToUint32(s string, defaultVal ...uint32) uint32
- func SubString(str string, start int, end int) string
- func TarDir(directory string, tarfilename string) error
- func Titlelize(str string) string
- func ToLower(str string) string
- func ToUpper(str string) string
- func Today() string
- func Trim(str string) string
- func TrimPrefix(str string, prefix string) string
- func ULID() string
- func Uint16ToBytes(num uint16) []byte
- func Uint32ToBytes(num uint32) []byte
- func Uint32ToString(num uint32) string
- func Uint64ToBytes(num uint64) []byte
- func Uint64ToString(i uint64) string
- func UnCompress(snappyEncodedBytes []byte) []byte
- func UnGzip(gzipPathFile string, destPath string) error
- func UnGzipBytes(gzipBytes []byte) ([]byte, error)
- func UnTar(tarFile string, dist string) error
- func UnZip(zipFile string, destPath string) error
- func UnZipBytes(bts []byte, destPath string) error
- func UnderlineToCamel(str string) string
- func Unique(strs []string) []string
- func Utf8ToGbk(utf8 []byte) []byte
- func WaitExit(fnExit func())
- func WaitGlcFinish()
- func Warn(v ...any)
- func WriteFileBytes(filename string, data []byte) error
- func WriteFileString(filename string, content string) error
- func Zip(srcFileOrPath string, zipPathFile string) error
- type AesEcb
- type BaiduOcr
- type Cache
- type DateFormat
- type EventBus
- type EventHandler
- type FasthttpServer
- func (f *FasthttpServer) BeforeRequestHandle(beforeHandle GlobalBeforeRequestHandler) *FasthttpServer
- func (f *FasthttpServer) EnableTsl(certData []byte, keyData []byte) *FasthttpServer
- func (f *FasthttpServer) FinallyRequestHandle(finallyHandle GlobalBeforeRequestHandler) *FasthttpServer
- func (f *FasthttpServer) Handle(method string, path string, handle fasthttp.RequestHandler) *FasthttpServer
- func (f *FasthttpServer) HandleGet(path string, handle fasthttp.RequestHandler) *FasthttpServer
- func (f *FasthttpServer) HandleNotFound(handle fasthttp.RequestHandler) *FasthttpServer
- func (f *FasthttpServer) HandlePost(path string, handle fasthttp.RequestHandler) *FasthttpServer
- func (f *FasthttpServer) SetPort(port string) *FasthttpServer
- func (f *FasthttpServer) SetServer(server *fasthttp.Server) *FasthttpServer
- func (f *FasthttpServer) Shutdown() error
- func (f *FasthttpServer) Start() error
- type Func
- type GlcClient
- type GlcData
- type GlcOptions
- type GlobalBeforeRequestHandler
- type JWT
- func (j *JWT) CreateToken(mapKv MapString, exp time.Duration) (string, error)
- func (j *JWT) IsExpired(token string) (bool, error)
- func (j *JWT) NewToken(username string) (string, error)
- func (j *JWT) Parse(token string) (MapString, error)
- func (j *JWT) RefreshToken(token string, exp time.Duration) (string, error)
- func (j *JWT) Validate(token string) (MapString, error)
- type LevelDB
- type LruCache
- type Map
- type MapString
- type Minio
- type OptionLevelDB
- type OsArgs
- func (o *OsArgs) GetArg(names ...string) string
- func (o *OsArgs) GetArgByIndex(index int) string
- func (o *OsArgs) GetArgIgnorecase(names ...string) string
- func (o *OsArgs) GetArgs(names ...string) []string
- func (o *OsArgs) HasArg(names ...string) bool
- func (o *OsArgs) HasArgIgnorecase(names ...string) bool
- func (o *OsArgs) HasCmd(names ...string) bool
- type Queue
- type SyncExecutor
- type TokenizerSego
Constants ¶
const ( FMT_MM_DD = "MM-dd" FMT_YYYYMM = "yyyyMM" FMT_YYYY_MM = "yyyy-MM" FMT_YYYY_MM_DD = "yyyy-MM-dd" FMT_YYYYMMDD = "yyyyMMdd" FMT_YYYYMMDDHHMMSS = "yyyyMMddHHmmss" FMT_YYYYMMDDHHMM = "yyyyMMddHHmm" FMT_YYYYMMDDHH = "yyyyMMddHH" FMT_YYMMDDHHMM = "yyMMddHHmm" FMT_MM_DD_HH_MM = "MM-dd HH:mm" FMT_MM_DD_HH_MM_SS = "MM-dd HH:mm:ss" FMT_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm" FMT_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss" FMT_YYYY_MM_DD_HH_MM_SS_SSS = "yyyy-MM-dd HH:mm:ss.SSS" FMT_MM_DD_EN = "MM/dd" FMT_YYYY_MM_EN = "yyyy/MM" FMT_YYYY_MM_DD_EN = "yyyy/MM/dd" FMT_MM_DD_HH_MM_EN = "MM/dd HH:mm" FMT_MM_DD_HH_MM_SS_EN = "MM/dd HH:mm:ss" FMT_YYYY_MM_DD_HH_MM_EN = "yyyy/MM/dd HH:mm" FMT_YYYY_MM_DD_HH_MM_SS_EN = "yyyy/MM/dd HH:mm:ss" FMT_YYYY_MM_DD_HH_MM_SS_SSS_EN = "yyyy/MM/dd HH:mm:ss.SSS" FMT_MM_DD_CN = "MM月dd日" FMT_YYYY_MM_CN = "yyyy年MM月" FMT_YYYY_MM_DD_CN = "yyyy年MM月dd日" FMT_MM_DD_HH_MM_CN = "MM月dd日 HH:mm" FMT_MM_DD_HH_MM_SS_CN = "MM月dd日 HH:mm:ss" FMT_YYYY_MM_DD_HH_MM_CN = "yyyy年MM月dd日 HH:mm" FMT_YYYY_MM_DD_HH_MM_SS_CN = "yyyy年MM月dd日 HH:mm:ss" FMT_HH_MM = "HH:mm" FMT_HH_MM_SS = "HH:mm:ss" FMT_HH_MM_SS_MS = "HH:mm:ss.SSS" )
日期格式模板
Variables ¶
This section is empty.
Functions ¶
func AmountToCny ¶
金额数字转人民币大写(最大支持千万亿,小数只精确到分,分以下舍去。超过支持的最大值时原样返回不转换)
1234567890123456.789 -> 壹仟贰佰叁拾肆万伍仟陆佰柒拾捌亿玖仟零壹拾贰万叁仟肆佰伍拾陆元柒角捌分 -1234567890123456.78 -> 负壹仟贰佰叁拾肆万伍仟陆佰柒拾捌亿玖仟零壹拾贰万叁仟肆佰伍拾陆元柒角捌分 12345.7 -> 壹万贰仟叁佰肆拾伍元柒角整 12345.0 -> 壹万贰仟叁佰肆拾伍元整 12345 -> 壹万贰仟叁佰肆拾伍元整 9002300040 -> 玖拾亿零贰佰叁拾万零肆拾元整 9002300043.0 -> 玖拾亿零贰佰叁拾万零肆拾叁元整 12345678901234567.781 -> 12345678901234567.781
func ContainsItem ¶ added in v0.10.20
判断数组中是否包含指定字符串
func ContentType ¶ added in v0.9.6
按扩展名如 .html 取ContentType,优先取自定义再取mime,都取不到返回"application/octet-stream"
func DecodeRsaByPriFile ¶
按Base64解码字符串后使用私钥文件进行RSA解密
func DecodeRsaBytesByPriFile ¶
使用私钥文件进行RSA解密
func EncodeRsaByPubFile ¶
使用公钥文件进行RSA加密后按Base64编码字符串
func EncodeRsaBytesByPubFile ¶
使用公钥文件进行RSA加密
func FasthttpPostJson ¶
使用Fasthttp进行Post请求,固定Content-Type:application/json;charset=UTF-8,其他自定义headers格式为 K:V
func FileNameWithoutExt ¶ added in v0.9.12
取不含扩展名的文件名,如“abc.txt时返回abc”
func Float64ToStringRoundDown ¶
float64 转 string,保留指定位数小数,后续小数位舍去
Float64ToStringRoundDown(1234567890123456,2) -> 1234567890123456.00 Float64ToStringRoundDown(999999999999.999,2) -> 999999999999.99
func FormatAmountRound ¶
float64 转 string,整数部分3位一撇,四舍五入保留或补足指定位数小数
func FormatRound ¶
float64 转 string,四舍五入保留或补足指定位数小数
func GenerateRSAKey ¶
创建秘钥
func GenerateRsaKeyFile ¶
创建秘钥文件(keySize通常是1024、2048、4096)
func GetFasthttpClientIp ¶ added in v0.10.7
func GetFasthttpClientIp(ctx *fasthttp.RequestCtx) string
取客户端IP
func GetGlcLatestVersion ¶ added in v0.10.17
func HexToRgb ¶
颜色转换(HEX => RGB)
rgb := HexToRgb("ccc") // rgb: [204 204 204] rgb := HexToRgb("aabbcc") // rgb: [170 187 204] rgb := HexToRgb("#aabbcc") // rgb: [170 187 204] rgb := HexToRgb("0xad99c0") // rgb: [170 187 204]
func HttpDownload ¶ added in v0.7.9
下载文件,自定义headers格式为 K:V
func HttpGetJson ¶
使用标准包进行Get请求,固定Content-Type:application/json;charset=UTF-8,其他自定义headers格式为 K:V
func HttpPostForm ¶
使用标准包进行Post请求,固定Content-Type:application/x-www-form-urlencoded,其他自定义headers格式为 K:V
func HttpPostJson ¶
使用标准包进行Post请求,固定Content-Type:application/json;charset=UTF-8,其他自定义headers格式为 K:V
func HttpUploadFile ¶ added in v0.7.8
使用标准包进行Post请求,固定Content-Type:multipart/form-data,其他自定义headers格式为 K:V
func IncludesStrIgnoreCase ¶ added in v0.10.13
判断字符串是否在切片中(忽略大小写)
func IsServerPortOpening ¶ added in v0.10.16
检测指定服务指定端口是否打开中
func Lcs ¶
最长公共子串 参考 http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_substring
func MeasureDisk ¶
检测磁盘(当前盘)
func MeasureDiskByPath ¶ added in v0.9.17
func MeasureDiskByPath(path string) (total uint64, used uint64, free uint64, usePercent float64, err error)
检测磁盘(指定路径所在磁盘)
func MeasureDiskFreeSpace ¶ added in v0.9.17
检测磁盘(指定路径所在磁盘的剩余空间)
func MeasureMemory ¶
检测内存
func MeasureSummary ¶
检测CPU、内存、磁盘使用占比
func MeasureSwap ¶
检测虚拟内存
func NormalizeVer ¶ added in v0.9.13
版本号格式转换便于比较大小,格式不符时返回原版本,例 v1.2.3 => v01.002.003
func NowTime ¶ added in v0.10.20
系统时间按指定的golang时间格式返回 (2006-01-02 15:04:05.000 代表 yyyy-MM-dd HH:mm:ss.SSS)
func ReaderToBytes ¶ added in v0.7.6
io.Reader 转 []byte
func Recover ¶ added in v0.10.18
func Recover()
捕获panic时打印异常日志避免崩溃,逻辑适用情况下,可简化用 defer Recover() 替代匿名函数的啰嗦写法
func ReplaceAllSpace ¶ added in v0.7.8
全部替换连续的空白
func StringToUint32 ¶
字符串(10进制无符号整数形式)转uint32,超过uint32最大值会丢失精度,转换失败时返回默认值
func ULID ¶
func ULID() string
ULID
ULID常作为UUID的替代方案,固定26位长度(10位时间戳+16位随机数),适用于数据库ID。 主要特点:毫秒精度有序(仅同一毫秒内无序)、无特殊字符
func UnZipBytes ¶ added in v0.20.1
func WriteFileBytes ¶
写文件(指定目录不存在时先创建,不含目录时存当前目录)
func WriteFileString ¶
写文件(指定目录不存在时先创建,不含目录时存当前目录)
Types ¶
type AesEcb ¶
type AesEcb struct {
// contains filtered or unexported fields
}
对称加密结构体
func (*AesEcb) DecodeBytes ¶
字节数组解密
type BaiduOcr ¶
type BaiduOcr struct {
// contains filtered or unexported fields
}
func NewBaiduOcr ¶
创建百度OCR对象(参数apiKey和secretKey在百度注册应用后获取)
func (*BaiduOcr) QuotaInvoice ¶
定额发票识别,支持png/jpeg/jpg/bpm/pdf类型(返回JSON识别结果)
支持对各类定额发票的发票代码、发票号码、金额、发票所在地、发票金额小写、省、市7个关键字段进行结构化识别
func (*BaiduOcr) VatInvoice ¶
增值税发票识别,支持png/jpeg/jpg/bpm/pdf类型(返回JSON识别结果)
支持对增值税普票、专票、卷票、电子发票的所有字段进行结构化识别, 包括发票基本信息、销售方及购买方信息、商品信息、价税信息等,其中四要素识别准确率超过 99.9%; 同时,支持对增值税卷票的 21 个关键字段进行识别,包括发票类型、发票代码、发票号码、机打号码、 机器编号、收款人、销售方名称、销售方纳税人识别号、开票日期、购买方名称、购买方纳税人识别号、 项目、单价、数量、金额、税额、合计金额(小写)、合计金额(大写)、校验码、省、市,四要素平均识别准确率可达95%以上。
type Cache ¶ added in v0.10.18
type Cache struct {
// contains filtered or unexported fields
}
缓存结构
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
事件总线结构体
type FasthttpServer ¶
type FasthttpServer struct {
// contains filtered or unexported fields
}
Fasthttp服务器结构体
func (*FasthttpServer) BeforeRequestHandle ¶
func (f *FasthttpServer) BeforeRequestHandle(beforeHandle GlobalBeforeRequestHandler) *FasthttpServer
注册全局前置拦截器(前置拦截器返回true时才会继续正常处理后续请求)
func (*FasthttpServer) EnableTsl ¶ added in v0.7.8
func (f *FasthttpServer) EnableTsl(certData []byte, keyData []byte) *FasthttpServer
开启TSL
func (*FasthttpServer) FinallyRequestHandle ¶ added in v0.7.11
func (f *FasthttpServer) FinallyRequestHandle(finallyHandle GlobalBeforeRequestHandler) *FasthttpServer
注册全局后置拦截器
func (*FasthttpServer) Handle ¶
func (f *FasthttpServer) Handle(method string, path string, handle fasthttp.RequestHandler) *FasthttpServer
注册指定方法的请求控制器
func (*FasthttpServer) HandleGet ¶
func (f *FasthttpServer) HandleGet(path string, handle fasthttp.RequestHandler) *FasthttpServer
注册GET方法的请求控制器
func (*FasthttpServer) HandleNotFound ¶ added in v0.7.10
func (f *FasthttpServer) HandleNotFound(handle fasthttp.RequestHandler) *FasthttpServer
注册NotFound的请求控制器
func (*FasthttpServer) HandlePost ¶
func (f *FasthttpServer) HandlePost(path string, handle fasthttp.RequestHandler) *FasthttpServer
注册POST方法的请求控制器
func (*FasthttpServer) SetPort ¶
func (f *FasthttpServer) SetPort(port string) *FasthttpServer
设定服务端口
func (*FasthttpServer) SetServer ¶
func (f *FasthttpServer) SetServer(server *fasthttp.Server) *FasthttpServer
设定服务配置项(参数中的Handler配置项将被忽略)
type GlcClient ¶ added in v0.10.1
type GlcClient struct {
// contains filtered or unexported fields
}
日志中心客户端结构体
日志中心见 https://github.com/gotoeasy/glogcenter
func (*GlcClient) WaitFinish ¶ added in v0.10.1
func (g *GlcClient) WaitFinish()
停止接收新的日志并等待日志全部输出完成
type GlcData ¶ added in v0.10.1
type GlcData struct { Text string `json:"text,omitempty"` // 【必须】日志内容,多行时仅为首行,直接显示用,是全文检索对象 Date string `json:"date,omitempty"` // 日期(格式YYYY-MM-DD HH:MM:SS.SSS) System string `json:"system,omitempty"` // 系统名 ServerName string `json:"servername,omitempty"` // 服务器名 ServerIp string `json:"serverip,omitempty"` // 服务器IP ClientIp string `json:"clientip,omitempty"` // 客户端IP TraceId string `json:"traceid,omitempty"` // 跟踪码 LogLevel string `json:"loglevel,omitempty"` // 日志级别 User string `json:"user,omitempty"` // 用户 }
日志接口数据结构体
type GlcOptions ¶
type GlcOptions struct { ApiUrl string // 日志中心的添加日志接口地址,默认取环境变量GLC_API_URL System string // 系统名(对应日志中心检索页面的分类栏),默认取环境变量GLC_SYSTEM,默认default ApiKey string // 日志中心的ApiKey,默认取环境变量GLC_API_KEY,默认X-GLC-AUTH:glogcenter Enable string // 是否开启发送到日志中心(true/false),默认取环境变量GLC_ENABLE,默认false EnableConsoleLog string // 是否禁止打印控制台日志(true/false),默认取环境变量GLC_ENABLE_CONSOLE_LOG,默认true LogLevel string // 能输出的日志级别(DEBUG/INFO/WARN/ERROR),默认取环境变量GLC_LOG_LEVEL,默认DEBUG ServerName string // 服务器名 ServerIp string // 服务器IP ClientIp string // 客户端IP TraceId string // 最终码 PrintSrcLine bool // 是否添加打印调用的文件行号,默认false // contains filtered or unexported fields }
日志中心选项
type GlobalBeforeRequestHandler ¶
type GlobalBeforeRequestHandler func(ctx *fasthttp.RequestCtx) bool
全局前置拦截器
type JWT ¶
type JWT struct {
// contains filtered or unexported fields
}
JWT结构体
func (*JWT) CreateToken ¶
创建令牌(默认HS256算法)
func (*JWT) RefreshToken ¶
续签令牌(复制原令牌后创建新令牌,原令牌可以是过期令牌)
type LevelDB ¶
type LevelDB struct {
// contains filtered or unexported fields
}
LevelDB结构体
func NewLevelDB ¶
func NewLevelDB(dbPath string, opt *OptionLevelDB) *LevelDB
创建LevelDB对象,参数dbPath为数据库名目录 实际每次调用都返回同一对象,opt仅首次调用时有效,opt为nil时使用默认值
type Minio ¶
type Minio struct {
// contains filtered or unexported fields
}
Minio客户端结构体
type OptionLevelDB ¶
type OptionLevelDB struct { // 最大空闲时间(分钟,0~240),达空闲时间后自动关闭,小于等于0时不自动关闭,默认15分钟,最长不超4小时 MaxIdleMinute int }
LevelDB选项
type OsArgs ¶ added in v0.17.0
type OsArgs struct { String string // 原命令 ArgCount int // 参数个数(含命令本身) LastArg string // 最后一个参数 // contains filtered or unexported fields }
命令行解析结果
func NewOsArgs ¶ added in v0.21.0
命令行解析器 约定: 参数名总是以“-”作为前缀,参数值紧跟参数名 指令默认总是非“-”前缀,但也可以通过参数自定义指令,指令总是忽略大小写
func (*OsArgs) GetArgByIndex ¶ added in v0.20.2
func (*OsArgs) GetArgIgnorecase ¶ added in v0.20.2
取指定参数名对应的值(忽略参数名大小写)
func (*OsArgs) GetArgs ¶ added in v0.21.0
取指定参数名对应的值切片,找不到时返回0长度的切片 例如命令 test -d /abc -d /def 用GetArgs("-d", "--dir")取得["/abc", "/def"]
func (*OsArgs) HasArgIgnorecase ¶ added in v0.20.2
判断是否含有指定参数名(忽略大小写)
type SyncExecutor ¶ added in v0.11.3
type SyncExecutor struct {
// contains filtered or unexported fields
}
type TokenizerSego ¶
type TokenizerSego struct {
// contains filtered or unexported fields
}
func NewTokenizerSego ¶
func NewTokenizerSego(dicFiles ...string) *TokenizerSego
创建中文分词器(sego) 从文件中载入词典,参数在前的词典文件优先,未指定时将简单的单字切分
func (*TokenizerSego) CutForSearch ¶
func (t *TokenizerSego) CutForSearch(str string) []string
按搜索引擎模式进行分词(自动去重、去标点符号、忽略大小写)
func (*TokenizerSego) CutForSearchEx ¶
func (t *TokenizerSego) CutForSearchEx(str string, addWords []string, delWords []string) []string
按搜索引擎模式进行分词(自动去重、去标点符号、忽略大小写),可自定义添加或删除分词
func (*TokenizerSego) IngoreWords ¶
func (t *TokenizerSego) IngoreWords(str ...string)
设定忽略词(比如分词结果不想包含无效词“的”或一些敏感词时,可以这里设定)
Source Files ¶
- ULID.go
- charset.go
- color.go
- compress_gzip.go
- compress_snappy.go
- compress_tar.go
- compress_zip.go
- data_struct_map.go
- encoding_aes.go
- encoding_base62.go
- encoding_base64.go
- encoding_hash.go
- encoding_jwt.go
- encoding_rsa.go
- event_bus.go
- exec_cmd.go
- exec_ssh_cmd.go
- http_content-type.go
- http_get_download.go
- http_get_json.go
- http_post_file.go
- http_post_form.go
- http_post_json.go
- http_post_json_fasthttp.go
- http_server_fasthttp.go
- ip_city.go
- logger.go
- logger_glc.go
- middleware_ai_baidu_ocr.go
- middleware_leveldb.go
- middleware_minio.go
- net_ping_port.go
- os_args.go
- os_env.go
- os_general.go
- os_measures.go
- os_signal_exit.go
- random.go
- string_array.go
- string_check.go
- string_lcs.go
- string_rune.go
- structure_cache_lur.go
- structure_cache_timeout.go
- structure_map.go
- structure_queue.go
- tokenizer_html_text.go
- tokenizer_sego.go
- util_array.go
- util_chan_fn.go
- util_converter.go
- util_date.go
- util_decimal.go
- util_file.go
- util_general.go
- util_number.go
- util_reflect_type.go