Documentation ¶
Index ¶
- func CleanPath(p string) string
- func Exist(path string) (bool, error)
- func ExpandEnv(data []byte) []byte
- func FormatLanguage(lang string) string
- func FormatVersion(ver string, minDepth int) string
- func GenUniqueId() string
- func HashSha1Crc32(s string) uint32
- func IsAllDigit(s string) bool
- func IsAllLetter(s string) bool
- func IsAllLower(s string) bool
- func IsAllUpper(s string) bool
- func MapClear(m map[string]interface{})
- func MapGet(m map[string]interface{}, key string, dftSplit ...string) interface{}
- func MapMerge(a map[string]interface{}, m ...map[string]interface{})
- func MapSet(m map[string]interface{}, key string, val interface{}, dftSplit ...string)
- func MapToSliceInt(sI interface{}) []int
- func MapToSliceString(sI interface{}) []string
- func Md5Bytes(v interface{}) []byte
- func Md5String(v interface{}) string
- func PanicTrace(maxDepth int, multiLine, debug bool) string
- func ParamsToMapSlice(m map[string]interface{}) map[string]interface{}
- func ST2Map(s interface{}, stayZero bool, dftTag ...string) map[string]interface{}
- func STMergeField(s1, s2 interface{})
- func STMergeSame(s1, s2 interface{})
- func SliceFilterInt(a []int, callbacks ...SliceFilterIntFunc) []int
- func SliceFilterString(a []string, callbacks ...SliceFilterStringFunc) []string
- func SliceSearch(n int, f func(int) bool) int
- func SliceSearchInt(a []int, x int) int
- func SliceSearchString(a []string, x string) int
- func SliceUniqueInt(a []int) []int
- func SliceUniqueString(a []string) []string
- func ToBool(v interface{}) bool
- func ToFloat(v interface{}) float64
- func ToInt(v interface{}) int
- func ToInt64(v interface{}) int64
- func ToString(v interface{}) string
- func VersionCompare(ver1, ver2 string) int
- type HashFnv64a
- type HashFunc
- type HashRing
- type SliceFilterIntFunc
- type SliceFilterStringFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanPath ¶
CleanPath is the URL version of path.Clean, it returns a canonical URL path for p, eliminating . and .. elements.
The following rules are applied iteratively until no further processing can be done:
- Replace multiple slashes with a single slash.
- Eliminate each . path name element (the current directory).
- Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
- Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path.
If the result of this process is an empty string, "/" is returned
func FormatLanguage ¶
FormatLanguage format lang to ll-CC format
func FormatVersion ¶
FormatVersion format version to have minimum depth, eg. FormatVersion("v10...2....2.1-alpha", 5) == "v10.2.2.1.0-alpha"
func HashSha1Crc32 ¶
func IsAllDigit ¶
func IsAllLetter ¶
func IsAllLower ¶
func IsAllUpper ¶
func MapToSliceInt ¶ added in v0.1.94
func MapToSliceInt(sI interface{}) []int
强制转换key为字符串数字map为[]int {"1":1} => [1]
func MapToSliceString ¶ added in v0.1.94
func MapToSliceString(sI interface{}) []string
强制转换key为字符串数字的map为[]string {"1":"ss"} => ["ss"]
func PanicTrace ¶
PanicTrace get panic trace
func ParamsToMapSlice ¶ added in v0.1.94
转换map为map/slice {"aaa[0][bbb]":"sss"} => {"aaa":[{"bbb":"sss"}]} 主要是转换map 中key为数字的map 转换为slice
func ST2Map ¶ added in v0.1.97
ST2Map Struct to map stayZero 是否保留零值 dftTag 获取标签为字段名,如果未传标签或者没有标签 获取字段名字,并首字母小写当作字段名
func STMergeField ¶
func STMergeField(s1, s2 interface{})
STMergeField merge the same or compatible field of s2 into s1, zero and unexported field will be skipped and embedded struct field will be treated as a single field.
func STMergeSame ¶
func STMergeSame(s1, s2 interface{})
STMergeSame merge none zero field of s2 into s1, s1 and s2 must have the same struct type. unexported field will be skipped and embedded struct field will be treated as a single field.
func SliceFilterInt ¶ added in v0.1.95
func SliceFilterInt(a []int, callbacks ...SliceFilterIntFunc) []int
SliceFilterInt 依次将 slice 中的每个值传递到 callback 函数。 如果 callback 函数返回 true,则 slice 的当前值会被包含在返回的结果slice中。 如果callback 未传 就会过滤零值
func SliceFilterString ¶ added in v0.1.95
func SliceFilterString(a []string, callbacks ...SliceFilterStringFunc) []string
SliceFilterString 依次将 slice 中的每个值传递到 callback 函数。 如果 callback 函数返回 true,则 slice 的当前值会被包含在返回的结果slice中。 如果callback 未传 就会过滤零值
func SliceSearch ¶
SliceSearch search in a slice has the length of n, return the first position where f(i) is true, -1 is returned if nothing found.
func SliceSearchInt ¶
SliceSearchInt search x in an int slice, return the first position of x, -1 is returned if nothing found.
func SliceSearchString ¶
SliceSearchString search x in a string slice, return the first position of x, -1 is returned if nothing found.
func SliceUniqueInt ¶
SliceUniqueInt retrieve unique items item from int slice.
func SliceUniqueString ¶
SliceUniqueString retrieve unique string items from string slice.
func VersionCompare ¶
VersionCompare compare versions like version_compare of php, special version strings these are handled in the following order, (any string not found) < dev < alpha = a < beta = b < rc < #(empty) < ##(digit) < pl = p, result: -1(ver1 < ver2), 0(ver1 == ver2), 1(ver1 > ver2)
Types ¶
type HashFnv64a ¶ added in v0.1.3
type HashFnv64a struct{}
func NewHashFnv64a ¶ added in v0.1.3
func NewHashFnv64a() *HashFnv64a
newHash returns a new 64-bit FNV-1a hash which makes no memory allocations. See https://en.wikipedia.org/wiki/Fowler–Noll–Vo_hash_function
func (*HashFnv64a) Value ¶ added in v0.1.3
func (h *HashFnv64a) Value(key string) uint64
Value gets the string and returns its uint64 hash value.
type HashRing ¶
type HashRing struct {
// contains filtered or unexported fields
}
func NewHashRing ¶
func NewHashRing(args ...interface{}) *HashRing
new hash ring, optional args: node string: node item key, multi node accepted, see AddNode(). spots int: num of virtual spots for each node, default 32. hashFunc HashFunc: function to calculate hash value, default HashSha1Crc32. eg. h := NewHashRing("127.0.0.1:6379", "127.0.0.1:6379", "127.0.0.1:6380")