Documentation
¶
Index ¶
- Constants
- Variables
- func BytesToString(b []byte) string
- func CN2Float64(cn string) (float64, error)
- func CN2Int64(cn string) (int64, error)
- 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 Float64ToCN(num float64) string
- func GenShortID() (string, error)
- func GetBytes(key interface{}) ([]byte, error)
- func GetDate() string
- func GetHostname() string
- func GetInternalIP() string
- func GetLocalIP() string
- func GetRealIP(r *http.Request) (ip string)
- func GetShowTime(ts time.Time) string
- func GetTodayDateInt() int
- func Int64ToCN(num int64) string
- 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 MustDecodeToFloat64(cn string) float64
- func MustZHToInt64(cn string) int64
- func Port(lis net.Listener) (int, bool)
- func RandomStr(n int) string
- func RegexpReplace(reg, src, temp string) string
- func SliceShuffle(slice []interface{})
- func SplitInt(s string) ([]int64, error)
- func StackTrace(msg string, err interface{}) string
- 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 Stringify(obj interface{}) string
- 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 ¶
Functions ¶
func CN2Float64 ¶
CN2Float64 : decode a chinese number string into Float64
func ConcatString ¶
ConcatString 连接字符串 NOTE: 性能比fmt.Sprintf和+号要好
func ConcatStringBySlash ¶
ConcatStringBySlash concat string by slash
func ExtractHostPort ¶
ExtractHostPort from address
func Float64ToCN ¶
Float64ToCN : convert float64 into Chinese number 由于float64固然存在的精度问题,本函数可能不会特别精准。所以小数部分最多精确到6位。
func IsInSlice ¶
func IsInSlice(value interface{}, sli interface{}) bool
IsInSlice 判断某一值是否在slice中 因为使用了反射,所以时间开销比较大,使用中根据实际情况进行选择
func MustDecodeToFloat64 ¶
MustDecodeToFloat64 : decode a chinese number string into Float64 without error
func MustZHToInt64 ¶
MustZHToInt64 : decode a chinese number string into Int64 without error
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 新建分页器