Documentation ¶
Index ¶
- Variables
- func AddDays(t time.Time, days int) time.Time
- func AddHours(t time.Time, hours int) time.Time
- func AddMinutes(t time.Time, minutes int) time.Time
- func AddMonths(t time.Time, months int) time.Time
- func AddSeconds(t time.Time, seconds int) time.Time
- func AddYears(t time.Time, years int) time.Time
- func ArrayToString(array []interface{}) string
- func CalcDaysFromYearMonth(year, month int) int
- func CanCallIsNil(v interface{}) bool
- func CompareTime(t1, t2 time.Time) bool
- func ConvertToStringSlice(data []interface{}) []string
- func ConvertToUTC(t time.Time) time.Time
- func CreateFilePath(filePath string) error
- func Decimal(value float64) float64
- func Decrypt(privateKeyFile, ciphertext string, types string) (plaintext string, err error)
- func DecryptOAEP(privateKeyFile, ciphertext string) (plaintext string, err error)
- func DecryptPKCS1v15(privateKeyFile, ciphertext string) (plaintext string, err error)
- func DeleteFile(name string) error
- func DirSize(dirname string) string
- func DownloadExcel(titleList []string, dataList []interface{}, filename ...string) (string, error)
- func Encrypt(privateKeyFile, ciphertext string, types string) (plaintext string, err error)
- func EncryptOAEP(publicKeyFile string, content string) (ciphertext string, err error)
- func EncryptPKCS1v15(publicKeyFile string, content string) (ciphertext string, err error)
- func EncryptPassword(password string, salt string) (string, error)
- func EncryptString(data string) (encrypt string, err error)
- func EndTime() int64
- func EndTimeByTime(ti int64) int64
- func EqualFoldWithoutChars(s1, s2 string) bool
- func FileSize(fileSize int64) string
- func FormatCmdKey(s string) string
- func FormatDuration(d time.Duration) string
- func FormatEnvKey(s string) string
- func FormatSize(size int64) string
- func FormatTimeRange(start, end time.Time) string
- func GenerateKeyPair(bits int, privateKeyFile string, publicKeyFile string) (err error)
- func GetAgeByBirthday(birthday time.Time) int
- func GetBeforeDay(year int, month time.Month, day int) int
- func GetBeforeMonth(year int, month time.Month, day int) time.Month
- func GetBeforeTime(year int, month time.Month, day int) time.Time
- func GetBeforeWeek(year int, month time.Month, day int) time.Weekday
- func GetBeforeYear(year int, month time.Month, day int) int
- func GetBetweenDates(sdate, edate string) []string
- func GetCurrentDateString() string
- func GetCurrentQuarter() int
- func GetDay() int
- func GetDayByTimeInt(t int64) int
- func GetDayByTimeLong(t int64) int
- func GetDayOfYear(t time.Time) int
- func GetDaysInMonth(year int, month time.Month) int
- func GetDaysInYear(year int) int
- func GetFirstDateOfMonth(year int, month time.Month) time.Time
- func GetFirstDateOfWeek(t time.Time) time.Time
- func GetFirstDayOfNextMonth(t time.Time) time.Time
- func GetHour() int
- func GetHourBetweenDates(sdate, edate string) []string
- func GetHourByTimeInt(t int64) int
- func GetHourByTimeLong(t int64) int
- func GetHourDiffer(startTime, endTime string) float64
- func GetLastDateOfMonth(year int, month time.Month) time.Time
- func GetLastDateOfWeek(t time.Time) time.Time
- func GetLastDayOfPreviousMonth(t time.Time) time.Time
- func GetLocalIP() (string, error)
- func GetMicrosecondsFromTime(t time.Time) int64
- func GetMin(a, b int64) int64
- func GetMinute() int
- func GetMinuteByTimeInt(t int64) int
- func GetMinuteByTimeLong(t int64) int
- func GetMinutesDiffer(startTime, endTime string) int
- func GetMondayTime(ti int64) int64
- func GetMonth() time.Month
- func GetMonthByTimeInt(t int64) time.Month
- func GetMonthByTimeLong(t int64) time.Month
- func GetMonthFirstDay() int64
- func GetMonthFirstDayByMonth(year int, month time.Month) int64
- func GetMonthLastDay() int64
- func GetMonthLastDayByMonth(year int, month time.Month) int64
- func GetNanosecondsFromTime(t time.Time) int64
- func GetNextWeekday(t time.Time) time.Time
- func GetPreviousWeekday(t time.Time) time.Time
- func GetPreviousYearMonth() (int, time.Month)
- func GetPreviousYearMonthBy(year int, month time.Month) (int, time.Month)
- func GetPublicIP() (ip string, err error)
- func GetQuarterByMonth(month time.Month) int
- func GetQuarterDay() (start, end string)
- func GetQuarterRange(year int, quarter int) (time.Time, time.Time)
- func GetRemainingDuration(t time.Time) time.Duration
- func GetSecond() int
- func GetSecondByTimeInt(t int64) int
- func GetSecondByTimeLong(t int64) int
- func GetStartQuarter() time.Month
- func GetStartQuarterByMonth(month time.Month) time.Month
- func GetTime(i, types int, begin string) (startTime, endTime string, duration int, unit string)
- func GetTimeByDay(day int) int64
- func GetTimeByInt(t int64) time.Time
- func GetTimeByType(types int) (index int, begin, end string)
- func GetTimeFromUnixMilli(millis int64) time.Time
- func GetTimeMills(t time.Time) int64
- func GetTimeTagGroup() string
- func GetTimeUnix(t time.Time) int64
- func GetTimeWithTimeZone(t time.Time, zoneName string) (time.Time, error)
- func GetTimeZone() *time.Location
- func GetUTCTime() time.Time
- func GetUnixMilliFromTime(t time.Time) int64
- func GetWeek() time.Weekday
- func GetWeekByTimeInt(t int64) time.Weekday
- func GetWeekByTimeLong(t int64) time.Weekday
- func GetWeekDay() (start, end string)
- func GetWeekOfYear(t time.Time) int
- func GetWeekStr() string
- func GetWeekStrByWeekInt(w int) string
- func GetYear() int
- func GetYearByTimeInt(t int64) int
- func GetYearByTimeLong(t int64) int
- func GetYesterday() int
- func GetYesterdayInt() int64
- func Go(fn func() error, errHandler ...ErrHandler)
- func InArray(target string, strArray []string) bool
- func InArrayInt(ids []int, id int) bool
- func IpInBlackListRange(ip string, ipList []string) (result bool)
- func IsBase64(str string) bool
- func IsBetween(t, start, end time.Time) bool
- func IsDebugEnabled() bool
- func IsEmpty(value interface{}) bool
- func IsExpired(t time.Time) bool
- func IsFloat(value interface{}) bool
- func IsInt(value interface{}) bool
- func IsJSONString(content string) bool
- func IsLeapYear(year int) bool
- func IsLetter(b byte) bool
- func IsLetterLower(b byte) bool
- func IsLetterUpper(b byte) bool
- func IsMap(value interface{}) bool
- func IsNil(value interface{}) bool
- func IsNumeric(s string) bool
- func IsSameDay(t1, t2 int64) bool
- func IsSameMinute(t1, t2 int64) bool
- func IsSlice(value interface{}) bool
- func IsStruct(value interface{}) bool
- func IsUint(value interface{}) bool
- func IsWeekend(t time.Time) bool
- func MapContainsPossibleKey(data map[string]interface{}, key string) bool
- func MapPossibleItemByKey(data map[string]interface{}, key string) (foundKey string, foundValue interface{})
- func Now() string
- func ParseDuration(s string) (time.Duration, error)
- func ParseIpRange(cidr string) ([]string, error)
- func ParsePrivateKeyFromPEM(pemBytes []byte) (privateKey *rsa.PrivateKey, err error)
- func ParsePublicKeyFromPEM(pemBytes []byte) (publicKey *rsa.PublicKey, err error)
- func Rand(min, max int) (int, error)
- func RandFloat(min, max float64) (float64, error)
- func RandIntSlice(slice []int) error
- func RandLowerString(length int) (string, error)
- func RandNumber(length int) (string, error)
- func RandString(length int) (string, error)
- func RandStringNoNumber(length int) (string, error)
- func RandUpperString(length int) (string, error)
- func ReadExcelFile(r *http.Request, tableName ...string) (rows [][]string, err error)
- func RemoveDuplicationMap(arr []string) []string
- func RemoveRepeatedElementAndEmpty(arr []int) []int
- func RemoveSymbols(s string) string
- func Replace(pattern string, replace, src []byte) ([]byte, error)
- func ReplaceByMap(origin string, replaces map[string]string) string
- func ReplaceString(pattern, replace, src string) (string, error)
- func ReplaceTemplate(content string, variable map[string]interface{}) (result string, err error)
- func SavePrivateKeyToFile(privateKey *rsa.PrivateKey, filename string) (err error)
- func SavePublicKeyToFile(publicKey *rsa.PublicKey, filename string) (err error)
- func SetDebugEnabled(enabled bool)
- func SetTimeZone(name string) error
- func SplitAndTrim(str, delimiter string, characterMask ...string) []string
- func StartAndEndDayTime(ti int64) [2]int64
- func StartAndEndMonthTime(ti int64) [2]int64
- func StartAndEndWeekTime(ti int64) [2]int64
- func StartAndEndYearTime(ti int64) [2]int64
- func StrToTime(date string) (int64, error)
- func StrToTimeFormat(date, format string) (int64, error)
- func StrToTimeFormatByLocal(date, format, localName string) (int64, error)
- func StripSlashes(str string) string
- func StructToMap(obj interface{}) map[string]interface{}
- func Throw(exception interface{})
- func Time() int64
- func TimeByTime(t time.Time) int64
- func TimeFormat(format string) string
- func TimeLong() int64
- func TimeLongToStr(t int64) string
- func TimeToFormat(t int64, format string) string
- func TimeToStr(t int64) string
- func ToExcel(dataList []interface{}) (content io.ReadSeeker)
- func ToMultiSheetExcel(data map[string][]any) (content io.ReadSeeker)
- func Trim(str string, characterMask ...string) string
- func Try(ctx context.Context, try func(ctx context.Context)) (err error)
- func TryCatch(ctx context.Context, try func(ctx context.Context), ...)
- func UTCTime() string
- func UcFirst(s string) string
- func UniqueCode(id int64, minLen int) (string, error)
- func ValidatePassword(password string, minimumLength int, requireComplexity int, requireDigit int, ...) (err error)
- func WalkDir(dirname string) ([]fileInfo, error)
- func ZeroTime() int64
- func ZeroTimeByLocal(localName string) (int64, error)
- func ZeroTimeByTime(ti int64) int64
- func ZeroTimeByTimeByLocal(ti int64, localName string) (int64, error)
- type ErrHandler
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultTrimChars are the characters which are stripped by Trim* functions in default. DefaultTrimChars = string([]byte{ '\t', '\v', '\n', '\r', '\f', ' ', 0x00, 0x85, 0xA0, }) )
var UniqueCodeMap = map[string][]string{
"0": {"A", "C"},
"1": {"D", "E"},
"2": {"F", "G", "Y"},
"3": {"H", "I"},
"4": {"Z", "K", "X"},
"5": {"L", "M", "W"},
"6": {"N", "O"},
"7": {"P", "Q", "Z"},
"8": {"R", "S", "V"},
"9": {"T", "U"},
}
UniqueCodeMap 用于生成唯一码的映射
Functions ¶
func AddMinutes ¶ added in v0.0.3
AddMinutes 在指定时间上添加分钟数
func AddSeconds ¶ added in v0.0.3
AddSeconds 在指定时间上添加秒数
func ArrayToString ¶
func ArrayToString(array []interface{}) string
func CalcDaysFromYearMonth ¶ added in v0.0.3
CalcDaysFromYearMonth 返回给定年份和月份的天数
func CanCallIsNil ¶ added in v0.0.3
func CanCallIsNil(v interface{}) bool
CanCallIsNil Can reflect.Value call reflect.Value.IsNil. It can avoid reflect.Value.IsNil panics.
func ConvertToStringSlice ¶ added in v0.0.7
func ConvertToStringSlice(data []interface{}) []string
func ConvertToUTC ¶ added in v0.0.3
ConvertToUTC 将指定时间转换为UTC时间
func CreateFilePath ¶ added in v0.0.3
CreateFilePath 创建路径
func DecryptOAEP ¶ added in v0.0.2
DecryptOAEP 使用私钥解密数据
func DecryptPKCS1v15 ¶ added in v0.0.2
DecryptPKCS1v15 使用私钥解密数据
func DownloadExcel ¶ added in v0.0.3
func EncryptOAEP ¶ added in v0.0.2
EncryptOAEP 使用公钥加密数据
func EncryptPKCS1v15 ¶ added in v0.0.2
EncryptPKCS1v15 使用公钥加密数据
func EncryptPassword ¶ added in v0.0.2
func EncryptString ¶ added in v0.0.2
EncryptString encrypts `data` using MD5 algorithms.
func EndTimeByTime ¶ added in v0.0.3
EndTimeByTime 获得时间戳对应的23点59分59秒时间戳
func EqualFoldWithoutChars ¶
EqualFoldWithoutChars checks string `s1` and `s2` equal case-insensitively, with/without chars '-'/'_'/'.'/' '.
func FormatCmdKey ¶
FormatCmdKey formats string `s` as command key using uniformed format.
func FormatDuration ¶ added in v0.0.3
FormatDuration 格式化时间间隔
func FormatEnvKey ¶
FormatEnvKey formats string `s` as environment key using uniformed format.
func FormatTimeRange ¶ added in v0.0.3
FormatTimeRange 格式化时间范围
func GenerateKeyPair ¶ added in v0.0.2
GenerateKeyPair 生成RSA密钥对
func GetAgeByBirthday ¶ added in v0.0.3
GetAgeByBirthday 根据生日计算年龄
func GetBeforeDay ¶ added in v0.0.3
GetBeforeDay 获得指定日期的前一天的日
func GetBeforeMonth ¶ added in v0.0.3
GetBeforeMonth 获得指定日期的前一天的月
func GetBeforeTime ¶ added in v0.0.3
GetBeforeTime 获得指定日期的前一天日期
func GetBeforeWeek ¶ added in v0.0.3
GetBeforeWeek 获得指定日期前一天的星期几
func GetBeforeYear ¶ added in v0.0.3
GetBeforeYear 获得指定日期的前一天的年
func GetBetweenDates ¶ added in v0.0.3
GetBetweenDates 根据开始日期和结束日期计算出时间段内所有日期
func GetCurrentDateString ¶ added in v0.0.3
func GetCurrentDateString() string
GetCurrentDateString 获取当前日期字符串
func GetDayByTimeLong ¶ added in v0.0.3
GetDayByTimeLong 获得指定时间戳的天数
func GetDaysInMonth ¶ added in v0.0.3
GetDaysInMonth 获取指定年月的天数
func GetFirstDateOfMonth ¶ added in v0.0.3
GetFirstDateOfMonth 获取指定年月的第一天
func GetFirstDateOfWeek ¶ added in v0.0.3
GetFirstDateOfWeek 获取指定日期所在周的周一
func GetFirstDayOfNextMonth ¶ added in v0.0.3
GetFirstDayOfNextMonth 获取下个月的第一天
func GetHourBetweenDates ¶ added in v0.0.3
GetHourBetweenDates 获取两个日期之间的所有小时
func GetHourByTimeInt ¶ added in v0.0.3
GetHourByTimeInt 获得指定时间戳的小时数
func GetHourByTimeLong ¶ added in v0.0.3
GetHourByTimeLong 获得指定时间戳的小时数
func GetHourDiffer ¶ added in v0.0.3
GetHourDiffer 计算两个时间差多少小时
func GetLastDateOfMonth ¶ added in v0.0.3
GetLastDateOfMonth 获取指定年月的最后一天
func GetLastDateOfWeek ¶ added in v0.0.3
GetLastDateOfWeek 获取指定日期所在周的周日
func GetLastDayOfPreviousMonth ¶ added in v0.0.3
GetLastDayOfPreviousMonth 获取上个月的最后一天
func GetMicrosecondsFromTime ¶ added in v0.0.3
GetMicrosecondsFromTime 获取时间的微秒数
func GetMinuteByTimeInt ¶ added in v0.0.3
GetMinuteByTimeInt 获得指定时间戳的分钟数
func GetMinuteByTimeLong ¶ added in v0.0.3
GetMinuteByTimeLong 获得指定时间戳的分钟数
func GetMinutesDiffer ¶ added in v0.0.3
GetMinutesDiffer 计算两个时间差多少分钟
func GetMondayTime ¶ added in v0.0.3
GetMondayTime 获得当前时间戳下的周一的时间戳
func GetMonthByTimeInt ¶ added in v0.0.3
GetMonthByTimeInt 获得指定时间戳的月份
func GetMonthByTimeLong ¶ added in v0.0.3
GetMonthByTimeLong 获得指定时间戳的月份
func GetMonthFirstDayByMonth ¶ added in v0.0.3
GetMonthFirstDayByMonth 获得指定月份的第一天日期
func GetMonthLastDayByMonth ¶ added in v0.0.3
GetMonthLastDayByMonth 获得指定月份的最后一天日期
func GetNanosecondsFromTime ¶ added in v0.0.3
GetNanosecondsFromTime 获取时间的纳秒数
func GetNextWeekday ¶ added in v0.0.3
GetNextWeekday 获取下一个工作日
func GetPreviousWeekday ¶ added in v0.0.3
GetPreviousWeekday 获取上一个工作日
func GetPreviousYearMonth ¶ added in v0.0.3
GetPreviousYearMonth 获得当前日期的上一个年月
func GetPreviousYearMonthBy ¶ added in v0.0.3
GetPreviousYearMonthBy 获得指定日期的前一个年月
func GetQuarterByMonth ¶ added in v0.0.3
GetQuarterByMonth 获取指定月份所属的季度
func GetQuarterDay ¶ added in v0.0.3
func GetQuarterDay() (start, end string)
GetQuarterDay 获得当前季度的初始和结束日期
func GetQuarterRange ¶ added in v0.0.3
GetQuarterRange 获取指定年份和季度的时间范围
func GetRemainingDuration ¶ added in v0.0.3
GetRemainingDuration 获取距离给定时间的剩余时间
func GetSecondByTimeInt ¶ added in v0.0.3
GetSecondByTimeInt 获得指定时间戳的秒数
func GetSecondByTimeLong ¶ added in v0.0.3
GetSecondByTimeLong 获得指定时间戳的秒数
func GetStartQuarter ¶ added in v0.0.3
GetStartQuarter 获取每个季度的起始月份
func GetStartQuarterByMonth ¶ added in v0.0.3
GetStartQuarterByMonth 获取指定月份所属季度的起始月份
func GetTimeByType ¶ added in v0.0.3
GetTimeByType 根据类型获取开始时间、结束时间及差值 1 天 2 周 3 月 4 年
func GetTimeFromUnixMilli ¶ added in v0.0.3
GetTimeFromUnixMilli 从毫秒级时间戳获取时间
func GetTimeTagGroup ¶ added in v0.0.3
func GetTimeTagGroup() string
GetTimeTagGroup 获取当前日期字符串,结果:2024:05
func GetTimeWithTimeZone ¶ added in v0.0.3
GetTimeWithTimeZone 获取指定时区的时间
func GetUnixMilliFromTime ¶ added in v0.0.3
GetUnixMilliFromTime 获取时间的毫秒级时间戳
func GetWeekByTimeInt ¶ added in v0.0.3
GetWeekByTimeInt 获得指定时间戳的星期几
func GetWeekByTimeLong ¶ added in v0.0.3
GetWeekByTimeLong 获得指定时间戳的星期几
func GetWeekOfYear ¶ added in v0.0.3
GetWeekOfYear 获取指定日期是所在年份的第几周
func GetWeekStrByWeekInt ¶ added in v0.0.3
GetWeekStrByWeekInt 获得周几字符串
func GetYearByTimeInt ¶ added in v0.0.3
GetYearByTimeInt 获得指定时间戳的年份
func GetYearByTimeLong ¶ added in v0.0.3
GetYearByTimeLong 获得指定时间戳的年份
func Go ¶ added in v0.0.3
func Go(fn func() error, errHandler ...ErrHandler)
Go runs the given function in a new goroutine with optional error handling
func InArrayInt ¶ added in v0.0.7
func IpInBlackListRange ¶ added in v0.0.2
IpInBlackListRange 判断IP是否在黑名单
func IsDebugEnabled ¶
func IsDebugEnabled() bool
IsDebugEnabled checks and returns whether debug mode is enabled. The debug mode is enabled when command argument "gf.debug" or environment "GF_DEBUG" is passed.
func IsFloat ¶
func IsFloat(value interface{}) bool
IsFloat checks whether `value` is type of float.
func IsLetterLower ¶
IsLetterLower checks whether the given byte b is in lower case.
func IsLetterUpper ¶
IsLetterUpper checks whether the given byte b is in upper case.
func IsNil ¶
func IsNil(value interface{}) bool
IsNil checks whether `value` is nil, especially for interface{} type value.
func IsNumeric ¶
IsNumeric checks whether the given string s is numeric. Note that float string like "123.456" is also numeric.
func IsSlice ¶
func IsSlice(value interface{}) bool
IsSlice checks whether `value` is type of slice.
func IsStruct ¶
func IsStruct(value interface{}) bool
IsStruct checks whether `value` is type of struct.
func MapContainsPossibleKey ¶
MapContainsPossibleKey checks if the given `key` is contained in given map `data`. It checks the key ignoring cases and symbols.
Note that this function might be of low performance.
func MapPossibleItemByKey ¶
func MapPossibleItemByKey(data map[string]interface{}, key string) (foundKey string, foundValue interface{})
MapPossibleItemByKey tries to find the possible key-value pair for given key ignoring cases and symbols.
Note that this function might be of low performance.
func ParseDuration ¶ added in v0.0.3
ParseDuration 解析时间间隔字符串
func ParseIpRange ¶ added in v0.0.2
ParseIpRange 用于将以 "," 分割的多个 CIDR 范围字符串解析为 CIDR 数组。 如果一个 CIDR 范围是以 "-" 分割的两个 IP 地址,那么我们会使用 binaryToInt 和 intToIP 函数将它们转换为整数并再次转换为 CIDR 字符串, 并将其加入到 CIDR 数组中。
func ParsePrivateKeyFromPEM ¶ added in v0.0.2
func ParsePrivateKeyFromPEM(pemBytes []byte) (privateKey *rsa.PrivateKey, err error)
ParsePrivateKeyFromPEM 从 PEM 格式的字节切片中解析 RSA 私钥
func ParsePublicKeyFromPEM ¶ added in v0.0.2
ParsePublicKeyFromPEM 从 PEM 格式的字节切片中解析 RSA 公钥
func RandLowerString ¶ added in v0.0.3
RandLowerString 返回指定长度的随机小写字母字符串
func RandNumber ¶ added in v0.0.3
RandNumber 返回指定长度的随机数字字符串
func RandString ¶ added in v0.0.3
RandString 返回指定长度的随机字符串(包括字母和数字)
func RandStringNoNumber ¶ added in v0.0.3
RandStringNoNumber 返回指定长度的随机字符串(仅包含字母)
func RandUpperString ¶ added in v0.0.3
RandUpperString 返回指定长度的随机大写字母字符串
func ReadExcelFile ¶ added in v0.0.3
ReadExcelFile 读取EXCEL文件
func RemoveDuplicationMap ¶ added in v0.0.7
RemoveDuplicationMap 数组去重
func RemoveRepeatedElementAndEmpty ¶ added in v0.0.7
func RemoveSymbols ¶
RemoveSymbols removes all symbols from string and lefts only numbers and letters.
func ReplaceByMap ¶
ReplaceByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-sensitively.
func ReplaceString ¶
ReplaceString replace all matched `pattern` in string `src` with string `replace`.
func ReplaceTemplate ¶ added in v0.0.2
func SavePrivateKeyToFile ¶ added in v0.0.2
func SavePrivateKeyToFile(privateKey *rsa.PrivateKey, filename string) (err error)
SavePrivateKeyToFile 将 RSA 私钥保存到文件
func SavePublicKeyToFile ¶ added in v0.0.2
SavePublicKeyToFile 将 RSA 公钥保存到文件
func SetDebugEnabled ¶
func SetDebugEnabled(enabled bool)
SetDebugEnabled enables/disables the internal debug info.
func SplitAndTrim ¶
SplitAndTrim splits string `str` by a string `delimiter` to an array, and calls Trim to every element of this array. It ignores the elements which are empty after Trim.
func StartAndEndDayTime ¶ added in v0.0.3
StartAndEndDayTime 获得时间戳对应的起始时间和结束时间
func StartAndEndMonthTime ¶ added in v0.0.3
StartAndEndMonthTime 获得指定时间戳的那个月的起始时间和结束时间
func StartAndEndWeekTime ¶ added in v0.0.3
StartAndEndWeekTime 获得指定时间戳的周一到周日的时间戳
func StartAndEndYearTime ¶ added in v0.0.3
StartAndEndYearTime 获得指定时间戳的那年的起始时间和结束时间
func StrToTimeFormat ¶ added in v0.0.3
StrToTimeFormat 将字符串转时间戳按格式
func StrToTimeFormatByLocal ¶ added in v0.0.3
StrToTimeFormatByLocal 将字符串转时间戳按格式和时区
func StripSlashes ¶
StripSlashes un-quotes a quoted string by AddSlashes.
func StructToMap ¶
func StructToMap(obj interface{}) map[string]interface{}
func Throw ¶ added in v0.0.3
func Throw(exception interface{})
Throw throws out an exception, which can be caught be TryCatch or recover.
func TimeToFormat ¶ added in v0.0.3
TimeToFormat 将时间戳转字符串并格式化
func ToExcel ¶ added in v0.0.3
func ToExcel(dataList []interface{}) (content io.ReadSeeker)
ToExcel 生成io.ReadSeeker 参数 titleList 为Excel表头,dataList 为数据
func ToMultiSheetExcel ¶ added in v0.0.3
func ToMultiSheetExcel(data map[string][]any) (content io.ReadSeeker)
ToMultiSheetExcel 生成io.ReadSeeker 参数 titleList 为Excel表头,dataList 为数据,data 键为sheet
func Trim ¶
Trim strips whitespace (or other characters) from the beginning and end of a string. The optional parameter `characterMask` specifies the additional stripped characters.
func Try ¶ added in v0.0.3
Try implements try... logistics using internal panic...recover. It returns error if any exception occurs, or else it returns nil.
func TryCatch ¶ added in v0.0.3
func TryCatch(ctx context.Context, try func(ctx context.Context), catch func(ctx context.Context, exception error))
TryCatch implements `try...catch..`. logistics using internal `panic...recover`. It automatically calls function `catch` if any exception occurs and passes the exception as an error. If `catch` is given nil, it ignores the panic from `try` and no panic will throw to parent goroutine.
But, note that, if function `catch` also throws panic, the current goroutine will panic.
func UcFirst ¶
UcFirst returns a copy of the string s with the first letter mapped to its upper case.
func UniqueCode ¶ added in v0.0.3
UniqueCode 根据给定的 ID 和最小长度生成唯一码
func ValidatePassword ¶ added in v0.0.7
func ZeroTimeByLocal ¶ added in v0.0.3
ZeroTimeByLocal 获得指定时区凌晨零点时间戳
func ZeroTimeByTime ¶ added in v0.0.3
ZeroTimeByTime 获得时间戳对应的凌晨0点时间戳
Types ¶
type ErrHandler ¶ added in v0.0.3
type ErrHandler func(interface{}, []byte)
ErrHandler is a function type for custom error handling
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package empty provides functions for checking empty/nil variables.
|
Package empty provides functions for checking empty/nil variables. |
Package errors provides functionalities to manipulate errors for internal usage purpose.
|
Package errors provides functionalities to manipulate errors for internal usage purpose. |
gcode
Package gcode provides universal error code definition and common error codes implementation.
|
Package gcode provides universal error code definition and common error codes implementation. |
gerror
Package gerror provides rich functionalities to manipulate errors.
|
Package gerror provides rich functionalities to manipulate errors. |
Package grand 提供高性能的随机字节/数字/字符串生成功能。
|
Package grand 提供高性能的随机字节/数字/字符串生成功能。 |
Package gstructs provides functions for struct information retrieving.
|
Package gstructs provides functions for struct information retrieving. |
Package ratelimit 提供了一个灵活的令牌桶实现,用于速率限制。
|
Package ratelimit 提供了一个灵活的令牌桶实现,用于速率限制。 |
Package reflection provides some reflection functions for internal usage.
|
Package reflection provides some reflection functions for internal usage. |
Package rwmutex provides switch of concurrent safety feature for sync.RWMutex.
|
Package rwmutex provides switch of concurrent safety feature for sync.RWMutex. |
Package gtag providing tag content storing for struct.
|
Package gtag providing tag content storing for struct. |