corex

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: GPL-3.0 Imports: 22 Imported by: 3

Documentation

Overview

*

  • @copyright www.ruomm.com
  • @author 牛牛-wanruome@126.com
  • @create 2024/5/14 10:11
  • @version 1.0

*

  • @copyright www.ruomm.com
  • @author 牛牛-wanruome@126.com
  • @create 2024/4/18 09:59
  • @version 1.0

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/24 11:23
  • @version 1.0

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/24 13:13
  • @version 1.0

Index

Constants

View Source
const (
	TIME_PATTERN_STANDARD       string = "2006-01-02 15:04:05"
	TIME_PATTERN_STANDARD_DAY   string = "2006-01-02"
	TIME_PATTERN_STANDARD_MONTH string = "2006-01"
	TIME_PATTERN_STANDARD_MILLS string = "2006-01-02 15:04:05.999"
	TIME_PATTERN_NOSPACE        string = "20060102150405"
	TIME_PATTERN_NOSPACE_DAY    string = "20060102"
	TIME_PATTERN_NOSPACE_MONTH  string = "200601"
	TIME_PATTERN_NOSPACE_MILLS  string = "20060102150405999"
)

Variables

This section is empty.

Functions

func ConcatDirPath

func ConcatDirPath(filePath string, subPath string, separatorRevise bool) string

*

  • 拼接2个目录完整目录路径 *
  • @param filePath 目录路径
  • @param subPath 次级目录路径
  • @param separatorRevise 是否修订名称中的文件分隔路径
  • @return 完整文件路径

func ConcatFilePath

func ConcatFilePath(filePath string, fileName string, separatorRevise bool) string

*

  • 拼接2个目录或1个目录1个文件为完整文件路径 *
  • @param filePath 目录路径
  • @param fileName 文件名称或目录路径
  • @param separatorRevise 是否修订名称中的文件分隔路径
  • @return 完整文件路径

func CopyFile

func CopyFile(pathSrc string, pathDest string) error

func FieldNameToSimply added in v1.1.9

func FieldNameToSimply(fieldName string) string

field名称简化

func FillStringLeft

func FillStringLeft(input string, padding string, len_total int) string

func FillStringRight

func FillStringRight(input string, padding string, len_total int) string

func FirstIndexOfFileSeparator

func FirstIndexOfFileSeparator(filePath string) int

*

  • 查找文件分割符号第一个的位置 *
  • @param filePath 文件路径
  • @return 返回分割符号第一个的位置位置,空返回-99,没有返回-1,

func Float64Format added in v0.3.0

func Float64Format(floatVal float64, prec int) float64

func Float64ToStr added in v0.3.0

func Float64ToStr(floatVal float64, prec int) string

func GetAbsDir

func GetAbsDir(relativePath string) string

func GetCurrentPath

func GetCurrentPath() string

获取当前的执行路径 C:\Users\Vic\AppData\Local\Temp\

func GetDayCountByMonth added in v0.7.2

func GetDayCountByMonth(year int, month int) int

获取一个月有多少天

func GetFileExtension added in v0.8.6

func GetFileExtension(filePath string) string

*

  • 获取文件的后缀从路径 *
  • <pre>
  • getFileExtension(null) = ""
  • getFileExtension("") = ""
  • getFileExtension(" ") = " "
  • getFileExtension("a.mp3") = "mp3"
  • getFileExtension("a.b.rmvb") = "rmvb"
  • getFileExtension("abc") = ""
  • getFileExtension("c:\\") = ""
  • getFileExtension("c:\\a") = ""
  • getFileExtension("c:\\a.b") = "b"
  • getFileExtension("c:a.txt\\a") = ""
  • getFileExtension("/home/admin") = ""
  • getFileExtension("/home/admin/a.txt/b") = ""
  • getFileExtension("/home/admin/a.txt/b.mp3") = "mp3"
  • </pre> *
  • @param filePath
  • @return

func GetFileName added in v0.8.6

func GetFileName(filePath string) string

*

  • 从路径获取文件名,包括后缀 *
  • <pre>
  • getFileName(null) = null
  • getFileName("") = ""
  • getFileName(" ") = " "
  • getFileName("a.mp3") = "a.mp3"
  • getFileName("a.b.rmvb") = "a.b.rmvb"
  • getFileName("abc") = "abc"
  • getFileName("c:\\") = ""
  • getFileName("c:\\a") = "a"
  • getFileName("c:\\a.b") = "a.b"
  • getFileName("c:a.txt\\a") = "a"
  • getFileName("/home/admin") = "admin"
  • getFileName("/home/admin/a.txt/b.mp3") = "b.mp3"
  • </pre> *
  • @param filePath 文件路径 -
  • @return 从路径文件名,包括后缀

func GetFileNameWithoutExtension added in v0.8.6

func GetFileNameWithoutExtension(filePath string) string

*

  • 从路径获取文件名,不包括后缀 *
  • <pre>
  • getFileNameWithoutExtension(null) = null
  • getFileNameWithoutExtension("") = ""
  • getFileNameWithoutExtension(" ") = " "
  • getFileNameWithoutExtension("abc") = "abc"
  • getFileNameWithoutExtension("a.mp3") = "a"
  • getFileNameWithoutExtension("a.b.rmvb") = "a.b"
  • getFileNameWithoutExtension("c:\\") = ""
  • getFileNameWithoutExtension("c:\\a") = "a"
  • getFileNameWithoutExtension("c:\\a.b") = "a"
  • getFileNameWithoutExtension("c:a.txt\\a") = "a"
  • getFileNameWithoutExtension("/home/admin") = "admin"
  • getFileNameWithoutExtension("/home/admin/a.txt/b.mp3") = "b"
  • </pre> *
  • @param filePath 文件路径 -
  • @return 从路径文件名,不包括后缀
  • @see

func GetLenForAny added in v0.3.5

func GetLenForAny(i interface{}) int

func GetMd5

func GetMd5(data string) string

func GetMd5WithSlat

func GetMd5WithSlat(data, slat string) string

func Int64ToStr

func Int64ToStr(i int64) string

func Int64ToStrFill added in v0.7.5

func Int64ToStrFill(i int64, len_total int) string

func IsAbsDir added in v0.2.8

func IsAbsDir(path string) bool

func IsAllChinese

func IsAllChinese(str string) bool

判断是全部是中文方法1

func IsAllChineseChar

func IsAllChineseChar(str string) bool

判断是全部是中文方法2

func IsChinese

func IsChinese(str string) bool

判断是否含有中文方法1

func IsChineseChar

func IsChineseChar(str string) bool

判断是否含有中文方法2

func IsEndWithFileSeparator

func IsEndWithFileSeparator(filePath string) bool

*

  • 文件路径是否以文件夹连接符号(File.separator)结尾 *
  • @param filePath 文件路径
  • @return 文件路径是否以文件夹连接符号(File.separator)结尾

func IsFileExit

func IsFileExit(file_path string) (bool, error)

func IsFileExitWithErr added in v0.2.4

func IsFileExitWithErr(file_path string) (bool, error)

func IsLastDayInMonth added in v0.7.2

func IsLastDayInMonth(year int, month int, day int) bool

判断是否一个月的最右一天

func IsLeapyear added in v0.7.2

func IsLeapyear(year int) bool

* 判断是否闰年

func IsNil added in v0.3.5

func IsNil(i interface{}) bool

func IsRegexMatch added in v1.2.1

func IsRegexMatch(reg_pattern string, val string) bool

func IsStartWithFileSeparator

func IsStartWithFileSeparator(filePath string) bool

*

  • 文件路径是否以文件夹连接符号(File.separator)开始 *
  • @param filePath 文件路径
  • @return 文件路径是否以文件夹连接符号(File.separator)开始

func JsonFormatByString added in v0.1.3

func JsonFormatByString(v any) (string, error)

func JsonParseByString added in v0.1.3

func JsonParseByString(str string, v any) error

func LastIndexOfFileSeparator

func LastIndexOfFileSeparator(filePath string) int

*

  • 查找文件分割符号最后的位置 *
  • @param filePath 文件路径
  • @return 返回分割符号最后的位置,空返回-99,没有返回-1,

func MatchStringCommon added in v0.1.2

func MatchStringCommon(pattern string, s string) bool

判断字符串是否匹配,支持正则表达式,支持开头结尾*通配符,支持严格匹配

func MatchStringEmptyPatternPass added in v0.1.5

func MatchStringEmptyPatternPass(pattern string, s string) bool

判断字符串是否匹配,支持正则表达式,支持开头结尾*通配符,支持严格匹配

func MkdirAll

func MkdirAll(file_path string) (bool, error)

func ParseFileSeparator

func ParseFileSeparator(filePath string) string

*

  • 依据文文件或文件夹路径智能获取文件夹连接符号(File.separator)。 *
  • @param filePath 文件或文件夹路径
  • @return 文件夹连接符号(File.separator)

func ParseToSubTag

func ParseToSubTag(tag string) []string

把tag分割为小功能块的子subTag

func ParseUrlWithContextPath

func ParseUrlWithContextPath(contextPath string, elem string) (string, error)

func QueryDayParseEnd added in v0.8.6

func QueryDayParseEnd(queryEnd string) string

解析查询的结束时间

func QueryDayParseStart added in v0.8.6

func QueryDayParseStart(queryStart string) string

解析查询的开始时间

func ReadFile

func ReadFile(path string) (string, error)

func ReadFileBuffer

func ReadFileBuffer(path string) (string, error)

func ServerTrace

func ServerTrace(tracePort int)

func SliceContains added in v0.9.7

func SliceContains(srcSlice interface{}, values ...interface{}) bool

判断Slice是否含有特定元素

func SliceContainsByKey added in v0.9.8

func SliceContainsByKey(srcSlice interface{}, key string, values ...interface{}) bool

判断Slice是否含有特定元素

func SliceDuplicates added in v0.9.6

func SliceDuplicates(srcSlice interface{}) bool

判断Slice是否含有重复元素

func SliceDuplicatesByKey added in v0.9.8

func SliceDuplicatesByKey(srcSlice interface{}, key string) bool

判断Slice是否含有重复元素

func SliceFindFieldValue added in v1.0.7

func SliceFindFieldValue(srcSlice interface{}, key string, destKey string, values ...interface{}) interface{}

获取Slice中的特定元素

func SliceFindValue added in v1.0.7

func SliceFindValue(srcSlice interface{}, key string, values ...interface{}) interface{}

获取Slice中的特定元素

func SliceIndexOf added in v1.1.6

func SliceIndexOf(srcSlice interface{}, values ...interface{}) int

判断Slice是否含有特定元素

func SliceIndexOfByKey added in v1.1.6

func SliceIndexOfByKey(srcSlice interface{}, key string, values ...interface{}) int

判断Slice是否含有特定元素

func SliceOnlyContains added in v0.9.8

func SliceOnlyContains(srcSlice interface{}, values ...interface{}) bool

判断Slice是否仅仅含有特定元素

func SliceOnlyContainsByKey added in v0.9.8

func SliceOnlyContainsByKey(srcSlice interface{}, key string, values ...interface{}) bool

判断Slice是否仅仅含有特定元素

func StoreSizeFormat added in v0.2.0

func StoreSizeFormat(byteSize int64, prec int) string

func StoreSizeParse added in v0.2.0

func StoreSizeParse(bytesizeStr string) (int64, error)

func StrToFloat64 added in v0.3.0

func StrToFloat64(str string) float64

func StrToInt64

func StrToInt64(str string) int64

func StrToUInt64

func StrToUInt64(str string) uint64

func StringToSlice added in v0.9.7

func StringToSlice(str string, sep string, emptyRetain bool) []string

转换string为slice

func TagIsValid

func TagIsValid(s string) bool

判断tag是否合法

func TimeAfterCurrent

func TimeAfterCurrent(timeLayout string, timeStr string) (bool, error)

func TimeBeforceCurrent

func TimeBeforceCurrent(timeLayout string, timeStr string) (bool, error)

func TimeCurrentDay added in v0.8.6

func TimeCurrentDay(currentDay *time.Time) string

获取当前天

func TimeCurrentMonth added in v0.8.6

func TimeCurrentMonth(currentDay *time.Time) string

获取当前月

func TimeFormatByMilliSeconds added in v0.2.1

func TimeFormatByMilliSeconds(timeLayout string, msec int64) string

格式化时间为字符串

func TimeFormatByString added in v0.1.3

func TimeFormatByString(timeLayout string, t *time.Time) string

格式化时间为字符串

func TimeNextDay added in v0.8.6

func TimeNextDay(currentDay *time.Time) string

获取后一天的时间

func TimeNextDayByString added in v1.0.5

func TimeNextDayByString(dayString string) string

获取后一天的时间

func TimeNextMonth added in v0.8.6

func TimeNextMonth(currentDay *time.Time) string

获取后一月的时间

func TimeNextMonthByString added in v1.0.5

func TimeNextMonthByString(monthString string) string

获取后一月的时间

func TimeNumberFormat added in v0.1.1

func TimeNumberFormat(timeNumberValue int64, prec int, secondMode bool) string

func TimeNumberParse added in v0.1.1

func TimeNumberParse(timenumStr string, secondMode bool) (int64, error)

func TimeOffsetDay added in v1.0.9

func TimeOffsetDay(currentDay *time.Time, offsetDay int) string

获取间隔特定天数的时间

func TimeOffsetDayByString added in v1.0.9

func TimeOffsetDayByString(dayString string, offsetDay int) string

获取间隔特定天数的时间

func TimeOffsetMonth added in v1.0.9

func TimeOffsetMonth(currentDay *time.Time, offsetMonth int) string

获取间隔特定月数的时间

func TimeOffsetMonthByString added in v1.0.9

func TimeOffsetMonthByString(monthString string, offsetMonth int) string

获取间隔特定月数的时间

func TimeParseByString added in v0.1.3

func TimeParseByString(timeLayout string, sTime string) (*time.Time, error)

TimeParseByString 解析字符串为时间

func TimePreDay added in v0.8.6

func TimePreDay(currentDay *time.Time) string

获取前一天的时间

func TimePreDayByString added in v1.0.5

func TimePreDayByString(dayString string) string

获取前一天的时间

func TimePreMonth added in v0.8.6

func TimePreMonth(currentDay *time.Time) string

获取前一月的时间

func TimePreMonthByString added in v1.0.5

func TimePreMonthByString(monthString string) string

获取前一月的时间

func TimeToFileName added in v0.1.4

func TimeToFileName(pTime *time.Time, filehead string, filetype string, fileTimeLayout string) string

*

  • 依据时间生成文件名称
  • @param pTime 时间
  • @param filehead 文件头
  • @param filetype 文件结尾
  • @param outTimeFormat SimpleDateFormat的格式,默认yyyyMMdd_HHmmss格式
  • @return 生成的文件名称

func TimeToYearMonthDay added in v1.0.8

func TimeToYearMonthDay(dayString string) (int64, int64, int64)

func TimeValidDayString added in v1.0.5

func TimeValidDayString(dayString string) bool

func TimeValidMonthString added in v1.0.5

func TimeValidMonthString(monthString string) bool

func ToSnakeCase

func ToSnakeCase(str string) string

驼峰转下划线工具

func ToTimeLocation

func ToTimeLocation() *time.Location

转换时间为本地时间

func ToTimeLocationPattern

func ToTimeLocationPattern(timezoneValue string, timezoneOffset int) *time.Location

转换时间为特定时区时间

func Uint64ToStr

func Uint64ToStr(i uint64) string

func Uint64ToStrFill added in v0.7.5

func Uint64ToStrFill(i uint64, len_total int) string

func WriteFile

func WriteFile(path string, content string) error

func WriteFileBuffer

func WriteFileBuffer(path string, content string) error

Types

type TagOptions

type TagOptions string

TagOptions is the string following a comma in a struct field's "json" tag, or the empty string. It does not include the leading comma.

func ParseTagToNameOption

func ParseTagToNameOption(tag string) (string, TagOptions)

parseTag splits a struct field's json tag into its name and comma-separated options. 把tag分割为名称和功能

func ParseTagToNameOptionFenHao added in v0.6.4

func ParseTagToNameOptionFenHao(tag string) (string, TagOptions)

把tag分割为小功能块的子subTag

func ParseTagToOptions

func ParseTagToOptions(tag string) []TagOptions

把tag分割为各个功能

func (TagOptions) Contains

func (o TagOptions) Contains(optionKey string) bool

Contains reports whether a comma-separated list of options contains a particular substr flag. substr must be surrounded by a string boundary or commas.

func (TagOptions) OptionValue

func (o TagOptions) OptionValue(optionKey string) string

返回一个控制指令的具体值,可以以=:.三种符号分割控制质量和控制值

type TokenHelper

type TokenHelper struct {
	TokenLen int
	Dicts    string
}

func (*TokenHelper) GenToken

func (t *TokenHelper) GenToken(token_len int) string

func (*TokenHelper) GenTokenDefault

func (t *TokenHelper) GenTokenDefault() string

func (*TokenHelper) GenTokenDefaultNoZeroStart added in v0.2.5

func (t *TokenHelper) GenTokenDefaultNoZeroStart() string

func (*TokenHelper) GenTokenNoZeroStart added in v0.2.5

func (t *TokenHelper) GenTokenNoZeroStart(token_len int) string

Jump to

Keyboard shortcuts

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