Documentation ¶
Index ¶
- Constants
- Variables
- func AST() aster
- func AlphaNumeric(s string) string
- func BytesToString(b []byte) string
- func Chinese(s string) string
- func CleanString(origStr string, args ...bool) string
- func Contains[T comparable](list []T, checkItem T) bool
- func CsvToInt32s(strValue string) []int32
- func CsvToInt64s(strValue string) []int64
- func CsvToInts(strValue string) []int
- func DeltaDays(t1, t2 time.Time) int
- func FromUnixTime(ts int64, format string) string
- func GenerateRandString(n int) string
- func Get1stDayOfWeek() string
- func GetBeginUnixTS(beginDate string) int64
- func GetBetweenDays(format, beginDate string, args ...string) ([]string, error)
- func GetDayBeginTimeSince(ts int64, ndays int) time.Time
- func GetDayEndTime(ndays int) time.Time
- func GetDayEndTimeSince(ts int64, ndays int) time.Time
- func GetEndUnixTS(endDate string) int64
- func GetMonthBeginTime(nmonth int) time.Time
- func GetMonthBeginTimeSince(ts int64, nmonth int) time.Time
- func GetMonthEndTime(nmonth int) time.Time
- func GetMonthEndTimeSince(ts int64, nmonth int) time.Time
- func GetNeo4jPathPattern(args ...int32) string
- func GetPagePositions(data interface{}, pageSize int) [][]int
- func GetSliceData(data interface{}) []interface{}
- func GetStartEndPosition(page, pageSize, total int64) (int64, int64)
- func GetYearBeginTime(nyear int) time.Time
- func GetYearEndTime(nyear int) time.Time
- func HashBytes(data []byte, length int) string
- func HashId(s string) uint32
- func HashString(s string, length int) string
- func Int32sToCsv(int32s []int32) string
- func Int64sToCsv(int64s []int64) string
- func IsAlphanumeric(s string) bool
- func IsEmptyJsonArray(data []byte) bool
- func IsEmptyJsonObject(data []byte) bool
- func IsImageData(data []byte) bool
- func IsNumeric(s string) bool
- func IsValidBeginEndTime(strBeginTime, strEndTime string) error
- func IsValidMobile(mobile string) bool
- func JsonArray(args ...any) []byte
- func JsonObject(args ...any) []byte
- func LogDebug(msg string, keyvals ...interface{})
- func LogError(msg string, keyvals ...interface{})
- func LogFatal(msg string, keyvals ...interface{})
- func LogWarn(msg string, keyvals ...interface{})
- func NewGoFile(pkgName string, imports map[string]string) gofile
- func Numeric(s string) string
- func ParseArgs(keyvals ...interface{}) (string, error, map[string]interface{})
- func ParseStrTime(value string) (*time.Time, error)
- func RecordErrorStack(app string)
- func RemoveInvisibleCharacter(origStr string) string
- func ReverseInt64Slice(numbers []int64) []int64
- func StringToBytes(s string) []byte
- func ToBytes(value interface{}) ([]byte, error)
- func ToCamelCase(str string) string
- func ToFixed(num float64, precision int) float64
- func ToInt32Slice(strSlice []string) []int32
- func ToInt64Slice(strSlice []string) []int64
- func ToIntSlice(strSlice []string) []int
- func ToSnakeCase(s string) string
- func ToString(value interface{}) (string, error)
- type AstAnnotation
- type AstFunction
- type LogLevel
- type Page
- type Pagination
- type Reflector
- type ValueItem
- type ValueMeta
Constants ¶
const (
DefaultPageSize = 10
)
Variables ¶
var ( EmptyJsonArray = StringToBytes("[]") EmptyJsonObject = StringToBytes("{}") )
var ( DefaultTimeLocation = time.FixedZone("CST", 8*3600) LayoutIsoDate = "2006-01-02" )
Functions ¶
func BytesToString ¶
BytesToString converts byte slice to string without a memory allocation.
func CleanString ¶
CleanString 处理字符串, args[0]为是否转换为小写
func Contains ¶
func Contains[T comparable](list []T, checkItem T) bool
func CsvToInt32s ¶
CsvToInt32s 将逗号分隔的string尝试转换成[1,2,3...]的int32 slice Csv means Comma Separated Value
func CsvToInt64s ¶
CsvToInt64s 将逗号分隔的string尝试转换成[1,2,3...]的int64 slice Csv means Comma Separated Value
func CsvToInts ¶ added in v0.0.4
CsvToInts 将逗号分隔的string尝试转换成[1,2,3...]的int slice Csv means Comma Separated Value
func FromUnixTime ¶
func GetBeginUnixTS ¶
GetBeginUnixTS 给出字符串的日期,例如2006-01或者2006-01-02, 返回对应的时间戳
func GetBetweenDays ¶
GetBetweenDays @description 获取开始日期和结束日期中间的所有日期列表 @param beginDate string 开始时间,格式为:2020-04-01 @param args ...string 如果指定了结束时间,则用结束时间,否则用当前时间,格式为:2020-04-01 @return 在这段日期时间内的所有天包含起始日期 []string,如:[2020-04-01 2020-04-02 2020-04-03]
func GetDayBeginTimeSince ¶
GetDayBeginTimeSince 获取从某个时间n天后第一秒的时间, 指定时间之前的日期00:00:00时间戳 ndays: -1表示前一天,0表示今天,1表示后一天
func GetDayEndTime ¶
GetDayEndTime 获取当前时间n天后最后一秒的时间, 当前时间后n天后的日期23:59:59时间戳 ndays: -1表示前一天,0表示今天,1表示后一天
func GetDayEndTimeSince ¶
GetDayEndTimeSince 获取从某个时间n天后最后一秒的时间, 指定时间之前的日期23:59:59时间戳 ndays: -1表示前一天,0表示今天,1表示后一天
func GetEndUnixTS ¶
func GetMonthBeginTime ¶
GetMonthBeginTime 获取当前时间所在月份指定月份的第一天的开始时间, 即某月第一天的0点 如果nmonth=-1, 则是上一个月的第一天的00:00:00, 如果nmonth=0, 则是本月的第一天的00:00:00 如果nmonth=1, 则是下个月的第一天的00:00:00
func GetMonthBeginTimeSince ¶
GetMonthBeginTimeSince 获取从某个时间n个月后第一天第一秒的时间 nmonth: -1表示前一个月,0表示本月,1表示后一个月
func GetMonthEndTime ¶
GetMonthEndTime 获取当前时间的指定月份的最后一天的23:59:59 即某月最后一天的23:59:59 如果nmonth=-1, 则是上一个月的最后一天的23:59:59 如果nmonth=0, 则是本月的最后一天的23:59:59 如果nmonth=1, 则是下个月的最后一天的23:59:59
func GetMonthEndTimeSince ¶
GetMonthEndTimeSince 获取从某个时间n个月最后一天最后一秒的时间, 指定时间之前的日期23:59:59时间戳 nmonth: -1表示前一个月,0表示本月,1表示后一个月
func GetNeo4jPathPattern ¶
GetNeo4jPathPattern 解析Neo4j语法的Variable-length pattern
func GetPagePositions ¶
GetPagePositions 获取分页的起始值列表 @return 返回一个二维数组, 第一维是多少页,第二维是每页[]int{start, end} e,g: 假设11个数的列表,分页pageSize是5,那么返回的是:
[]int{ []int{0, 5}, []int{5, 10}, []int{10, 11}, }
func GetSliceData ¶
func GetSliceData(data interface{}) []interface{}
GetSliceData 将传过来的数据转换成[]interface{}
func GetStartEndPosition ¶ added in v0.0.8
GetStartEndPosition 如果是按列表slice进行翻页的话, 计算slice的起始index
func GetYearBeginTime ¶
GetYearBeginTime 获取当前时间所在年份指定年的第一天的开始时间, 即某年第一天的0点 如果nyear=-1, 则是上一年的第一天的00:00:00, 如果nyear=0, 则是本年的第一天的00:00:00 如果nyear=1, 则是下一年的第一天的00:00:00
func GetYearEndTime ¶
GetYearEndTime 获取当前时间的指定年份的最后一天的23:59:59 即某年最后一天的23:59:59 如果nyear=-1, 则是上一个年的最后一天的23:59:59 如果nyear=0, 则是本年的最后一天的23:59:59 如果nyear=1, 则是下一年的最后一天的23:59:59
func HashString ¶ added in v0.0.2
func Int32sToCsv ¶
Int32sToCsv 将int32 slice转换成用逗号分隔的字符串: 1,2,3
func Int64sToCsv ¶
Int64sToCsv 将int64 slice转换成用逗号分隔的字符串: 1,2,3
func IsAlphanumeric ¶
IsAlphanumeric check if the string contains only letters and numbers. Empty string is valid.
func IsEmptyJsonArray ¶ added in v0.0.3
IsEmptyJsonArray 是否是空json array
func IsEmptyJsonObject ¶ added in v0.0.3
IsEmptyJsonObject 是否是空json object
func IsValidBeginEndTime ¶
IsValidBeginEndTime check if it is valid begin/end time
func IsValidMobile ¶
IsValidMobile check if the string is valid chinese mobile number
func JsonObject ¶
JsonObject 将object转换成[]byte数据,如果object为nil或空则返回空json object bytes
func ParseStrTime ¶
ParseStrTime iso time string转化为时间,layout必须为 "2006-01-02 15:04:05"
func RemoveInvisibleCharacter ¶
RemoveInvisibleCharacter 去除掉不能显示的字符
func ReverseInt64Slice ¶
ReverseInt64Slice 将[]int64 slice倒序重新排列
func StringToBytes ¶
StringToBytes converts string to byte slice without a memory allocation.
func ToCamelCase ¶
ToCamelCase converts from underscore separated form to camel case form.
func ToInt32Slice ¶
ToInt32Slice 将string slice转换成[1,2,3...]的int32 slice
func ToInt64Slice ¶
ToInt64Slice 将string slice转换成[1,2,3...]的int64 slice
func ToIntSlice ¶ added in v0.0.4
ToIntSlice 将string slice转换成[1,2,3...]的int slice
func ToSnakeCase ¶
ToSnakeCase converts from camel case form to underscore separated form.
Types ¶
type AstFunction ¶
type AstFunction struct { Receiver string Function string Annotations map[string]*AstAnnotation // annotationName->*AstAnnotation PlainComments []string // 去除注解后的注释 }
type Pagination ¶ added in v0.0.8
func NewPagination ¶ added in v0.0.8
func NewPagination(page, pageSize int64) Pagination
NewPagination 获取分页对象
func (Pagination) GetLimitClause ¶ added in v0.0.8
func (p Pagination) GetLimitClause() string
GetLimitClause 获取limit sql子句
type Reflector ¶
type Reflector interface { GetFuncName(fn any) string //从函数实例获取函数名 GetStructName(obj any) string // 从实例获取结构名 GetVarName(v any) string // 获取变量名 StructSet(obj any, nilField any, val any) error // 给结构体设置field类型的值 MatchReceiverMethods(receiver any, matchFn any) map[string]any // 匹配receiver的所有methods中与matchFn签名参数类似的方法 GetFuncSignature(fn any) string // 获取函数签名信息 InspectValue(v any) *ValueMeta // 检索Value的信息 FuncEqual(fn1, fn2 any) bool // 函数是否相等 }