util

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TT1 TimeTemplate = "2006-01-02 15:04:05"
	TT2              = "2006/01/02 15:04:05"
	TT3              = "2006-01-02"
	TT4              = "20060102"
	TT5              = "15:04:05"
)
View Source
const CNM = `` /* 306-byte string literal not displayed */
View Source
const DEEPLINK = `` /* 152-byte string literal not displayed */
View Source
const EMTF = `` /* 1003-byte string literal not displayed */
View Source
const HOLLSON = `` /* 301-byte string literal not displayed */
View Source
const SYBS = `
           __     
  _____ __/ /  ___
 (_-/ // / _ \(_-<
/___\_, /_.__/___/
   /___/          `

Variables

This section is empty.

Functions

func ContainByte

func ContainByte(o byte, a ...byte) bool

元素o是否包含在切片a中

byte

func ContainFloat32

func ContainFloat32(o float32, a ...float32) bool

元素o是否包含在切片a中

float32

func ContainFloat64

func ContainFloat64(o float64, a ...float64) bool

元素o是否包含在切片a中

float64

func ContainInt

func ContainInt(o int, a ...int) bool

元素o是否包含在切片a中

int

func ContainInt32

func ContainInt32(o int32, a ...int32) bool

元素o是否包含在切片a中

int32

func ContainInt64

func ContainInt64(o int64, a ...int64) bool

元素o是否包含在切片a中

int64

func ContainString

func ContainString(o string, a ...string) bool

元素o是否包含在切片a中

string

func Decimal

func Decimal(value float64) float64

保留两位

func Duplicate

func Duplicate(a interface{}) (ret []interface{})

切片去重

func Duration

func Duration(hours int) time.Duration

构造时间差

func GetGmtimeStr

func GetGmtimeStr() string

func GetLocaltimeStr

func GetLocaltimeStr() string

func GetTmShortStr

func GetTmShortStr(tm time.Time, format string) string

func GetTmStr

func GetTmStr(tm time.Time, format string) string

func GetUnixTimeShortStr

func GetUnixTimeShortStr(ut int64, format string) string

func GetUnixTimeStr

func GetUnixTimeStr(ut int64, format string) string

func GoStdRubyDate

func GoStdRubyDate() string

func GoStdTime

func GoStdTime() string

func GoStdUnixDate

func GoStdUnixDate() string

func Greatest

func Greatest(arr []time.Time) time.Time

func Is400

func Is400(str string) bool

是否匹配400电话

func IsChineseCharacter

func IsChineseCharacter(str string) bool

是否全是中文

func IsEmail

func IsEmail(str string) bool

是否匹配邮箱格式

func IsFloat

func IsFloat(str string) bool

整数或者小数

func IsHMS

func IsHMS(str string) bool

是否匹配日期格式

hh:mm:ss

func IsHMS_APM

func IsHMS_APM(str string) bool

是否匹配日期格式(AP)

hh:mm:ss xx

func IsIP

func IsIP(str string) bool

是否匹配IP格式

func IsNumber

func IsNumber(str string) bool

是否是数字

func IsPhone

func IsPhone(str string) bool

是否匹配手机号格式

func IsSpecialSymbols

func IsSpecialSymbols(str string) bool

是否以特殊符号开头

!@#$%^&*()_+-={}|[]\:";'<>?,./ 等

func IsTel

func IsTel(str string) bool

是否匹配电话格式

func IsYMD

func IsYMD(str string) bool

是否匹配年份格式

(?!0000)  闰年:2016-02-29

func IsYMDHMS

func IsYMDHMS(str string) bool

是否匹配日期时间格式

YYYY-MM-DD
(?!0000)  闰年:2016-02-29

func JsonFormat

func JsonFormat(o interface{}) string

将结构体o以json的格式输出

参考fmt.Stringer接口

func RandIntn

func RandIntn(n int) int

func RetroWeekN

func RetroWeekN(n time.Weekday) time.Time

向前的倒退的周N

func ReverseByteSlice

func ReverseByteSlice(s []byte)

切片反转 - byte

func ReverseFloat32Slice

func ReverseFloat32Slice(s []float32)

切片反转 - float32

func ReverseFloat64Slice

func ReverseFloat64Slice(s []float64)

切片反转 - float64

func ReverseInt32Slice

func ReverseInt32Slice(s []int32)

切片反转 - int32

func ReverseInt64Slice

func ReverseInt64Slice(s []int64)

切片反转 - int64

func ReverseIntSlice

func ReverseIntSlice(s []int)

切片反转 - int

func ReverseStringSlice

func ReverseStringSlice(s []string)

切片反转 - string

func SQLInInt

func SQLInInt(items ...int) (inSql string)

将切片拼接成「sql in」语句

如:{1,3,5,7,9} ==> "1,3,5,7,9"

func SQLInInt32

func SQLInInt32(items ...int32) (inSql string)

将切片拼接成「sql in」语句

如:{1,3,5,7,9} ==> "1,3,5,7,9"

func SQLInInt64

func SQLInInt64(items ...int64) (inSql string)

将切片拼接成「sql in」语句

如:{1,3,5,7,9} ==> "1,3,5,7,9"

func SQLInString

func SQLInString(items ...string) (inSql string)

将切片拼接成「sql in」语句

如:{"aa","bb","cc"} ==> "'1','3','5','7','9'"

func StrToInt64

func StrToInt64(num string) int64

数据转换

func StrToTime

func StrToTime(timeStr string, template TimeTemplate) (time.Time, error)

func T3

func T3(b bool, x, y interface{}) interface{}

三目运算

func TimeOfYMD

func TimeOfYMD(tm time.Time) time.Time

获取年月日部分

Types

type TimeSlice

type TimeSlice []time.Time

func (TimeSlice) Len

func (s TimeSlice) Len() int

func (TimeSlice) Less

func (s TimeSlice) Less(i, j int) bool

func (TimeSlice) Swap

func (s TimeSlice) Swap(i, j int)

type TimeTemplate

type TimeTemplate string

Jump to

Keyboard shortcuts

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