Documentation ¶
Index ¶
- Constants
- func BytesToString(b []byte) string
- func ConcatString(s ...string) string
- func ConcatStringBySlash(s ...string) string
- func Extract(hostPort string, lis net.Listener) (string, error)
- func ExtractHostPort(addr string) (host string, port uint64, err error)
- func GenShortID() (string, error)
- func GetAvatarURL(cdnURL, key string) string
- func GetBytes(key interface{}) ([]byte, error)
- func GetDate() string
- func GetDefaultAvatarURL(cdnURL string) string
- func GetHostname() string
- func GetInternalIP() string
- func GetLocalIP() string
- func GetQiNiuPublicAccessURL(cdnURL, path string) string
- func GetRealIP(r *http.Request) (ip string)
- func GetShowTime(ts time.Time) string
- func GetTodayDateInt() int
- func IsEmpty(s string) bool
- func IsInSlice(value interface{}, sli interface{}) bool
- func IsZero(i ...interface{}) bool
- func JoinInt(is []int64) string
- func Md5(str string) (string, error)
- func Port(lis net.Listener) (int, bool)
- func PrintStackTrace(msg string, err interface{}) string
- func RandomStr(n int) string
- func RegexpReplace(reg, src, temp string) string
- func SliceShuffle(slice []interface{})
- func SplitInt(s string) ([]int64, error)
- func StringSliceContains(ss []string, s string) bool
- func StringSliceEqual(a, b []string) bool
- func StringSliceReflectEqual(a, b []string) bool
- func StringToBytes(s string) []byte
- func StringToInt(str string) (int, error)
- func StringToInt64(str string) (int64, error)
- func StringToUint64(str string) (uint64, error)
- func TimeLayout() string
- func TimeToShortString(ts time.Time) string
- func TimeToString(ts time.Time) string
- func Uint64DeleteElemInSlice(i int, s []uint64) []uint64
- func Uint64DeleteElemInSliceWithOrder(i int, s []uint64) []uint64
- func Uint64ShuffleSlice(a []uint64) []uint64
- func Uint64SliceReverse(a []uint64) []uint64
- type Pagination
Constants ¶
const ( // DateTime date time layout DateTime = "2006-01-02 15:04:05" // DateOnly date layout DateOnly = "2006-01-02" // TimeOnly time layout TimeOnly = "15:04:05" )
Variables ¶
This section is empty.
Functions ¶
func ConcatString ¶
ConcatString 连接字符串 NOTE: 性能比fmt.Sprintf和+号要好
func ConcatStringBySlash ¶ added in v1.8.0
ConcatStringBySlash concat string by slash
func ExtractHostPort ¶
ExtractHostPort from address
func GetAvatarURL ¶
GetAvatarURL user's avatar, if empty, use default avatar
func GetDefaultAvatarURL ¶
GetDefaultAvatarURL 获取默认头像
func GetQiNiuPublicAccessURL ¶
GetQiNiuPublicAccessURL 获取七牛资源的公有链接 无需配置bucket, 域名会自动到域名所绑定的bucket去查找
func IsInSlice ¶
func IsInSlice(value interface{}, sli interface{}) bool
IsInSlice 判断某一值是否在slice中 因为使用了反射,所以时间开销比较大,使用中根据实际情况进行选择
func PrintStackTrace ¶ added in v1.7.0
PrintStackTrace print stack info
func StringSliceContains ¶
StringSliceContains 字符串切片中是否包含另一个字符串 来自go源码 net/http/server.go
func StringSliceEqual ¶
StringSliceEqual 判断 string和slice 是否相等 使用了传统的遍历方式
func StringSliceReflectEqual ¶
StringSliceReflectEqual 判断 string和slice 是否相等 因为使用了反射,所以效率较低,可以看benchmark结果
func Uint64DeleteElemInSlice ¶
Uint64DeleteElemInSlice 从slice删除元素 fast version, 会改变顺序 i:slice的索引值 s: slice
func Uint64DeleteElemInSliceWithOrder ¶
Uint64DeleteElemInSliceWithOrder 从slice删除元素 slow version, 保持原有顺序 i:slice的索引值 s: slice
func Uint64ShuffleSlice ¶
Uint64ShuffleSlice 对slice进行随机
func Uint64SliceReverse ¶
Uint64SliceReverse 对uint64 slice 反转
Types ¶
type Pagination ¶
Pagination 分页器
func NewPagination ¶
func NewPagination(req *http.Request, total int, pageSize int) *Pagination
NewPagination 新建分页器