Documentation ¶
Index ¶
- Constants
- Variables
- func AddDaysForCurrent(days int) time.Time
- func AddHoursForCurrent(hours int) time.Time
- func AddMinutesForCurrent(minutes int) time.Time
- func AorB(condition bool, a, b string) string
- func Br2String(source string) string
- func ByteCountIEC(b int) string
- func CheckNotExist(src string) bool
- func CheckPermission(src string) bool
- func Command(cmd string, args ...string) (string, error)
- func CompareVersion(src, toCompare string) bool
- func CompressedHTML(h *template.HTML)
- func CopyMap(m map[string]string) map[string]string
- func CreateCurrentDateDir(rootPath string, perm os.FileMode) (string, error)
- func CreateDateDir(rootPath string, datetime time.Time, perm os.FileMode) (string, error)
- func CreateDir(perm os.FileMode, args ...string) (string, error)
- func CurrentTimeToString(args ...interface{}) string
- func DateToIntSlice(date time.Time) []int
- func DateToStringSlice(date time.Time) []string
- func DateToUnixNanoTimestamp(date time.Time) int64
- func DateToUnixTimestamp(date time.Time) int64
- func DatetimeAdd(firstDatetime time.Time, duration time.Duration) time.Time
- func DatetimeAddDay(firstDatetime time.Time, dayValue int) time.Time
- func DatetimeAddHour(firstDatetime time.Time, hourValue int) time.Time
- func DatetimeAddMinute(firstDatetime time.Time, minuteValue int) time.Time
- func DatetimeAddSecond(firstDatetime time.Time, secondValue int) time.Time
- func DatetimeSub(firstDatetime, secondDatetime time.Time) time.Duration
- func DeleteFile(filename string, args ...string) error
- func EmailFilter(source string) string
- func EncodeMd5(value string) string
- func FileCreate(content bytes.Buffer, name string)
- func FileExist(path string) bool
- func FileIsExists(filename string) bool
- func FileMonitoringById(ctx context.Context, filePth string, id string, group string, ...)
- func FilterHostProtocol(path string) string
- func FilterInt64Slice(all, other []int64) []int64
- func FilterStringSlice(all, other []string) []string
- func FilterUint64Slice(all, other []uint64) []uint64
- func FindProcessID(processName string) (int, error)
- func Float64ToString(value float64) string
- func FormatFileSize(fileSize int64) (size string)
- func FromBase64(data string, args ...bool) (string, error)
- func FromJson(jsonString string, object interface{}) error
- func FromXml(xmlString string, object interface{}) error
- func GetAbsolutePath(filePath string) string
- func GetCurrentDay() int32
- func GetCurrentDayCount(args ...time.Time) int
- func GetCurrentHour() int32
- func GetCurrentMinute() int32
- func GetCurrentMonth() int32
- func GetCurrentMonthMaxDate(args ...time.Time) time.Time
- func GetCurrentMonthMaxNanoTimestamp(args ...time.Time) int64
- func GetCurrentMonthMaxTimestamp(args ...time.Time) int64
- func GetCurrentMonthMinDate(args ...time.Time) time.Time
- func GetCurrentMonthMinNanoTimestamp(args ...time.Time) int64
- func GetCurrentMonthMinTimestamp(args ...time.Time) int64
- func GetCurrentPath() string
- func GetCurrentSecond() int32
- func GetCurrentTime() time.Time
- func GetCurrentTimeStr() string
- func GetCurrentTimeUnix() int64
- func GetCurrentWeek() int
- func GetCurrentWeekDayRange() (int, int)
- func GetCurrentYear() int32
- func GetDateDay(datetime time.Time) int32
- func GetDateHour(datetime time.Time) int32
- func GetDateMinute(datetime time.Time) int32
- func GetDateMonth(datetime time.Time) int32
- func GetDateRangeForWeekInDateRange(startDate, endDate time.Time, week int) []time.Time
- func GetDateSecond(datetime time.Time) int32
- func GetDateYear(datetime time.Time) int32
- func GetDateYearMonthDay(args ...time.Time) int
- func GetDatetimeForDateAndTimeString(date time.Time, timeString string) time.Time
- func GetDatetimeWeekString(datetime time.Time) string
- func GetDayCount(datetime time.Time) int
- func GetExt(fileName string) string
- func GetField(v reflect.Value, i int) reflect.Value
- func GetFileContent(fullFilename string) ([]byte, error)
- func GetFilePath(filePath string) (string, string)
- func GetFileSize(filename string) int64
- func GetFileType(ft string) string
- func GetFilename(filePath string) (string, string, string)
- func GetImageType(p string) (string, error)
- func GetMaxDate(dtTime time.Time) time.Time
- func GetMaxDateNanoTimestamp(dtTime time.Time) int64
- func GetMaxDateTimestamp(dtTime time.Time) int64
- func GetMinDate(dtTime time.Time) time.Time
- func GetMinDateNanoTimestamp(dtTime time.Time) int64
- func GetMinDateTimestamp(dtTime time.Time) int64
- func GetNow() time.Time
- func GetParentDirectory(directory string) string
- func GetRelativePath(fullpath string) string
- func GetSize(f multipart.File) (int, error)
- func GetStringCount(sourceString string) int
- func GetSubString(sourceString string, count int, args ...string) string
- func GetTimeIntervalStringSlice(startDate, endDate time.Time, minutes int64) []string
- func GetTokenString() string
- func GetType(p string) (string, error)
- func GetUint64SliceRange(int64Slice []uint64, count int) []uint64
- func GetUtcNow() time.Time
- func GetWeek(datetime time.Time) int
- func HasPrefix(content, target string) bool
- func HasPrefixSuffix(content, target string) bool
- func HasSuffix(content, target string) bool
- func HtmlToPureText(html string) string
- func IdCardNumFilter(source string) string
- func InArray(arr []string, str string) bool
- func Int64Diff(one, two []int64) []int64
- func Int64Inter(one, two []int64) []int64
- func Int64SliceToString(intSlice []int64, args ...string) string
- func Int64SliceToStringSlice(values []int64) []string
- func Int64ToString(value int64) string
- func Int64Union(one, two []int64) []int64
- func IntSliceToDate(intSlice []int) (time.Time, error)
- func IsAlpha(sourceString string, args ...interface{}) bool
- func IsAlphaOrNumber(sourceString string) bool
- func IsChinese(sourceString string, args ...interface{}) bool
- func IsDateGreaterThan(firstDatetime, secondDatetime time.Time) bool
- func IsDateLessThan(firstDatetime, secondDatetime time.Time) bool
- func IsDecimals(str ...string) bool
- func IsDirectory(filename string) bool
- func IsEmail(sourceString string, args ...interface{}) bool
- func IsEngishLowCase(str ...string) bool
- func IsEnglish(str ...string) bool
- func IsEnglishCap(str ...string) bool
- func IsFile(filename string) bool
- func IsHiddenFile(name string) bool
- func IsID(str ...string) bool
- func IsIdCardNum(sourceString string) bool
- func IsInteger(str ...string) bool
- func IsJSON(str string) bool
- func IsMatchStringSliceCount(srcSlice []string, maxCount, stringItemCount int) bool
- func IsMobile(sourceString string) bool
- func IsNotExistMkDir(src string) error
- func IsNumber(sourceString string, args ...interface{}) bool
- func IsPwd(str ...string) bool
- func IsRegexpMatch(sourceString string, pattern string) bool
- func IsSql(source string) bool
- func IsTelphone(sourceString string) bool
- func IsUsername(sourceString string, args ...interface{}) bool
- func JSON(a interface{}) string
- func JoinMapToString(params map[string]string, filterKeys []string, isEscape bool) string
- func JsonToStruct(data string, value interface{}) error
- func MapDataSign(params map[string]string, secret string) (string, bool)
- func Match(p string, s string) bool
- func Md5(value string) string
- func Min(x, y int) int
- func MinutesToTimeString(minutes int64) string
- func MkDir(src string) error
- func MkFileIfNotExist(path string)
- func MkdirIfNotExist(path string)
- func MobileFilter(source string) string
- func ModFloat64(value float64, length int) float64
- func MonthsToSeasons(months []int32) []string
- func MoveFile(srcFilename, dstPath string, creationDate time.Time) (string, error)
- func MustOpen(fileName, filePath string) (*os.File, error)
- func Nonzero(v reflect.Value) bool
- func NormalizeEOL(input []byte) []byte
- func Open(name string, flag int, perm os.FileMode) (*os.File, error)
- func PackageName(v interface{}) string
- func ParseBool(s string) bool
- func ParseFileContentType(fileName string) string
- func ParseFloat32(f string) float32
- func ParseHTML(name, tmpl string, param interface{}) template.HTML
- func ParseText(name, tmpl string, param interface{}) string
- func ParseTime(stringTime string) time.Time
- func PathCreate(dir string) error
- func PathExist(addr string) bool
- func RandNum(min, max int) int
- func RandNumStr(n int) string
- func RandOrd(n int) string
- func RandStr(n int, letter string) string
- func RandString(n int) string
- func Random(strings []string) ([]string, error)
- func ReplaceAll(s string, oldnew ...string) string
- func ReplaceNth(s, old, new string, n int) string
- func ReverseString(sourceString string) string
- func ReverseUint64Slice(int64Slice []uint64)
- func SaveFile(data []byte, filename, basePath string, args ...string) (string, error)
- func SetDefault(value, condition, def string) string
- func Split(str, sep string) []string
- func SqlFilter(source string) string
- func StartProcess(processName string) (string, error)
- func StopProcess(processName string) (string, error)
- func String2Br(source string) string
- func StringDiff(one, two []string) []string
- func StringInter(one, two []string) []string
- func StringReplace(sourceString string, args ...string) string
- func StringSliceLatest(srcSlice []string, maxCount int) []string
- func StringSliceToDate(dateStringSlice []string) (time.Time, error)
- func StringSliceToInt64Slice(values []string) []int64
- func StringSliceToString(stringSlice []string, args ...string) string
- func StringSliceToUint64Slice(values []string) []uint64
- func StringToBool(stringValue string) bool
- func StringToFloat64(stringValue string) float64
- func StringToInt(e string) (int, error)
- func StringToInt32(stringValue string) int32
- func StringToInt64(stringValue string) int64
- func StringToInt64Slice(sourceString string, args ...string) []int64
- func StringToIntSlice(sourceString string, args ...string) []int
- func StringToStringSlice(sourceString string, args ...string) []string
- func StringToTime(datetimeString string, args ...interface{}) (time.Time, error)
- func StringToUint32(stringValue string) uint32
- func StringToUint64(stringValue string) uint64
- func StringToUint64Slice(sourceString string, args ...string) []uint64
- func StringUnion(one, two []string) []string
- func StructToJson(value interface{}) (res string, err error)
- func SubString(src string, start, end int) string
- func Substr(s string, pos, length int) string
- func TimeSincePro(then time.Time, m map[string]string) string
- func TimeStringAddMinutes(timeString string, minutes int) string
- func TimeToFriendString(datetime time.Time, args ...interface{}) string
- func TimeToString(datetime time.Time, args ...interface{}) string
- func TimeToUnix(e time.Time) int64
- func ToBase64(data string, args ...bool) string
- func ToJson(object interface{}) (string, error)
- func ToLowerUnderlinedNamer(name string) string
- func ToXml(object interface{}) (string, error)
- func TrimSpaceLine(source string) string
- func Uint64Diff(one, two []uint64) []uint64
- func Uint64Inter(one, two []uint64) []uint64
- func Uint64SliceToString(uintSlice []uint64, args ...string) string
- func Uint64SliceToStringSlice(values []uint64) []string
- func Uint64ToString(value uint64) string
- func Uint64Union(one, two []uint64) []uint64
- func UnixDate() time.Time
- func UnixNanoTimestamp() int64
- func UnixNanoTimestampToDate(unixNanoTimestamp int64) time.Time
- func UnixTimestamp() int64
- func UnixTimestampDate() time.Time
- func UnixTimestampToDate(unixTimestamp int64) time.Time
- func UnixToTime(e string) (datatime time.Time, err error)
- func UploadFileTo(fh *multipart.FileHeader, destDirectory string) (int64, error)
- func Uuid(length int64) string
- func WeekDay(t time.Time) string
- func WrapURL(u string) string
- type FileInfo
- type FileInfoList
- type IFileSize
- type Mailer
- type ReplaceHelper
- type StringSet
- func (set *StringSet) Add(i string) bool
- func (set *StringSet) Contains(i string) bool
- func (set *StringSet) Index(c string) int
- func (set *StringSet) ItemByIndex(idx int) string
- func (set *StringSet) Len() int
- func (set *StringSet) Remove(i string)
- func (set *StringSet) Sort()
- func (set *StringSet) String() string
Constants ¶
const ( B = 1 KB = 1024 * B MB = 1024 * KB GB = 1024 * MB )
const ( Minute = 60 Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day Month = 30 * Day Year = 12 * Month )
Seconds-based time units
Variables ¶
Functions ¶
func AddMinutesForCurrent ¶
* 在当前的日期时间增加指定的分钟数,返回日期时间 *
func ByteCountIEC ¶ added in v0.0.8
func CheckNotExist ¶ added in v0.0.8
CheckNotExist check if the img exists
func CheckPermission ¶ added in v0.0.8
CheckPermission check if the img has permission
func CompareVersion ¶
func CompressedHTML ¶
func CreateCurrentDateDir ¶ added in v0.0.8
* 根据当前日期在指定根目录下创建多级目录 *
func CreateDateDir ¶ added in v0.0.8
* 根据指定的日期在指定的目录下创建多级目录 *
func DateToUnixNanoTimestamp ¶
* 获取指定日期的Unix纳秒时间戳 *
func DatetimeAdd ¶
* firstDatetime加上时间间隔duration,返回日期时间 *
func DatetimeAddDay ¶
* firstDatetime加上指定的天数,返回日期时间 *
func DatetimeAddHour ¶
* firstDatetime加上指定的小时数,返回日期时间 *
func DatetimeAddMinute ¶
* firstDatetime加上指定的分钟数,返回日期时间 *
func DatetimeAddSecond ¶
* firstDatetime加上指定的秒数,返回日期时间 *
func DatetimeSub ¶
* firstDatetime减去secondDatetime,返回时间间隔 *
func FileCreate ¶ added in v0.0.8
func FileMonitoringById ¶ added in v0.0.8
func FilterInt64Slice ¶
* 过滤int64数组(从all中过滤所有other中的数据,返回未被过滤的数据集合) *
func FilterStringSlice ¶
* 过滤字符数组(从all中过滤所有other中的数据,返回未被过滤的数据集合) *
func FilterUint64Slice ¶
* 过滤uint64数组(从all中过滤所有other中的数据,返回未被过滤的数据集合) *
func FormatFileSize ¶ added in v0.0.8
字节的单位转换 保留两位小数
func GetCurrentMonthMaxDate ¶
* 获取当月里最大日期时间(2016-01-02 23:59:59 999999999) *
func GetCurrentMonthMaxNanoTimestamp ¶
* 获取当月里最大日期时间戳(当月最后一天最大时间),单位纳秒 *
func GetCurrentMonthMaxTimestamp ¶
* 获取当月里最大日期时间戳(当月最后一天最大时间),单位秒 *
func GetCurrentMonthMinDate ¶
* 获取当月里最小日期时间(2016-01-01 0:0:0 0) *
func GetCurrentMonthMinNanoTimestamp ¶
* 获取当月里最小日期时间戳(当月第一天最小时间),单位纳秒 *
func GetCurrentMonthMinTimestamp ¶
* 获取当月里最小日期时间戳(当月第一天最小时间),单位秒 *
func GetCurrentTime ¶
func GetCurrentTimeStr ¶
func GetCurrentTimeStr() string
func GetCurrentTimeUnix ¶
func GetCurrentTimeUnix() int64
func GetCurrentWeekDayRange ¶
* 获取当前周对应的月份里的日期范围(minDay in month, maxDay in month) *
func GetDateRangeForWeekInDateRange ¶
* 获取日期范围内的所属周几的日期集合 * week:从1开始,1表示周一,依次类推 *
func GetDatetimeForDateAndTimeString ¶
* 日期时间的日期部分和时间字符串连接,返回日期时间 *
func GetDatetimeWeekString ¶
* 获取日期时间的日期和星期字符串 *
func GetFileContent ¶ added in v0.0.8
* 获取文件内容 *
func GetFilePath ¶ added in v0.0.8
* 获取路径里的路径和文件名 *
func GetFilename ¶ added in v0.0.8
* 获取路径里的文件名,不带扩展名的文件名,扩展名 *
func GetImageType ¶ added in v0.0.8
GetImageType 获取Image文件类型
func GetMaxDate ¶
* 返回日期的最大日期时间(2016-01-02 23:59:59 999999999) *
func GetMaxDateNanoTimestamp ¶
* 获取日期的最大日期时间戳,单位纳秒 *
func GetMinDateNanoTimestamp ¶
* 获取日期的最小日期时间戳,单位纳秒 *
func GetParentDirectory ¶ added in v0.0.8
func GetRelativePath ¶ added in v0.0.8
* 获取全文件路径的相对路径 *
func GetSubString ¶
* 获取指定长度的字符串 *
func GetTimeIntervalStringSlice ¶
* 获取一段时间范围内指定间隔的时间段集合 *
func GetUint64SliceRange ¶
* 获取指定个数的uint64slice *
func HtmlToPureText ¶
func Int64SliceToString ¶
* 用指定的字符串把int64切片链接为字符串 *
func Int64SliceToStringSlice ¶
* 整型64切片转为字符串切片 *
func IsDateGreaterThan ¶
* 判断firstDatetime是否在secondDatetime的后面,即firstDatetime比secondDatetime日期大 *
func IsDateLessThan ¶
* 判断firstDatetime是否在secondDatetime的前面,即firstDatetime比secondDatetime日期小 *
func IsDirectory ¶ added in v0.0.8
func IsEngishLowCase ¶
************************ 英文类型 ************************ 仅小写
func IsHiddenFile ¶ added in v0.0.8
func IsMatchStringSliceCount ¶
* 判断字符串切片及单个项的字符数是否匹配指定大小, *
func IsNotExistMkDir ¶ added in v0.0.8
IsNotExistMkDir create a directory if it does not exist
func IsUsername ¶
* 是否用户名(以英文字母开头,后面跟英文字母和数据以及下划线) *
func JoinMapToString ¶
* 字典参数升序排序,组成键=值集合,然后把集合用&拼接成字符串 *
func JsonToStruct ¶
func MapDataSign ¶
* 签名算法 * params里的每个Value都需要进行url编码 * fmt.Sprintf("%s=%s", key, url.QueryEscape(value)) *
func MkFileIfNotExist ¶ added in v0.0.8
func MkFileIfNotExist(path string)
func MkdirIfNotExist ¶ added in v0.0.8
func MkdirIfNotExist(path string)
func NormalizeEOL ¶ added in v0.0.8
NormalizeEOL will convert Windows (CRLF) and Mac (CR) EOLs to UNIX (LF)
func PackageName ¶
func PackageName(v interface{}) string
func ParseFileContentType ¶ added in v0.0.8
func ParseFloat32 ¶
func PathCreate ¶ added in v0.0.8
func RandNumStr ¶
func RandString ¶
func ReplaceAll ¶
func ReplaceNth ¶
func SetDefault ¶
func StringReplace ¶
* 字符串替换 * sourceString: 原始字符串 * args[0...n-2]: 被替换字符串集合 * args[n-1]: 替换字符串 *
func StringSliceLatest ¶
* 保留指定长度字符串切片,前面的数据移除 *
func StringSliceToDate ¶
* 日期字符串切片转成日期 *
func StringSliceToInt64Slice ¶
* 字符串切片转为整型64切片 *
func StringSliceToString ¶
* 用指定的字符串链接字符串切片 *
func StringSliceToUint64Slice ¶
* 字符串切片转为无符号整型64切片 *
func StringToInt ¶
func StringToInt64Slice ¶
* 用指定的字符串把源字符串分隔为int64切片 *
func StringToIntSlice ¶
* 用指定的字符串把源字符串分隔为int切片 *
func StringToStringSlice ¶
* 用指定的字符串分隔源字符串为字符串切片 *
func StringToTime ¶
* 字符串转时间 * isUtc参数决定传入的日期字符串是否是utc日期 * isUtc:bool | format:string * 返回UTC日期 *
func StringToUint64Slice ¶
* 用指定的字符串把源字符串分隔为uint64切片 *
func StructToJson ¶
func TimeSincePro ¶
TimeSincePro calculates the time interval and generate full user-friendly string.
func TimeStringAddMinutes ¶
* 时间字符串加指定的分钟数,返回时间字符串 *
func TimeToFriendString ¶
* 日期时间转换成友好的显示字符串 * isUtc:bool | format:string *
func ToLowerUnderlinedNamer ¶
ToLowerUnderlinedNamer 转换为小写下划线命名
func Uint64SliceToString ¶
* 用指定的字符串把uint64切片链接为字符串 *
func Uint64SliceToStringSlice ¶
* 无符号整型64切片转为字符串切片 *
func UnixNanoTimestampToDate ¶
* 根据Unix纳秒时间戳返回日期 *
func UnixTimestampToDate ¶
* 根据Unix时间戳返回日期 *
func UploadFileTo ¶ added in v0.0.8
func UploadFileTo(fh *multipart.FileHeader, destDirectory string) (int64, error)
Types ¶
type FileInfo ¶ added in v0.0.8
type FileInfo struct { Filename string `form:"filename" json:"filename"` //原始文件名(test.jpg) Data []byte `form:"data" json:"data"` //文件字节切片 Size int64 `form:"size" json:"size"` //大小(单位:字节) Duration int64 `form:"duration" json:"duration"` //时长(单位:秒) Path string `form:"path" json:"path"` //全路径(本地磁盘或第三方文件系统) }
func GetHttpRequestFile ¶ added in v0.0.8
* 获取Http请求里的文件数据 * maxSize: 文件大小限制,0表示不限制 *
type FileInfoList ¶ added in v0.0.8
type FileInfoList []*FileInfo
type ReplaceHelper ¶ added in v0.0.8
func (*ReplaceHelper) DoWrok ¶ added in v0.0.8
func (h *ReplaceHelper) DoWrok() error