Documentation ¶
Index ¶
- func CleanPath(p string) string
- 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) interface{}
- func MapMerge(a map[string]interface{}, m ...map[string]interface{})
- func MapSet(m map[string]interface{}, key string, val interface{})
- func Md5Bytes(v interface{}) []byte
- func Md5String(v interface{}) string
- func PanicTrace(maxDepth int, multiLine bool) string
- func STMergeField(s1, s2 interface{})
- func STMergeSame(s1, s2 interface{})
- 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 ToString(v interface{}) string
- func VersionCompare(ver1, ver2 string) int
- func YamlDecode(r io.Reader, out interface{}, strict ...bool) error
- func YamlEncode(w io.Writer, in interface{}) error
- func YamlMarshal(in interface{}) ([]byte, error)
- func YamlUnmarshal(in []byte, out interface{}, strict ...bool) error
- type HashFunc
- type HashRing
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 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 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)
func YamlDecode ¶
YamlDecode wrapper for yaml.Decoder, strict is for Decoder.SetStrict(). if type of out is map[string]interface{}, *map[string]interface{}, the inner map[interface{}]interface{} will fix to map[string]interface{} recursively. if type of out is *interface{}, the underlying type of out will change to *map[string]interface{}.
func YamlEncode ¶
YamlEncode wrapper for yaml.Encoder.
func YamlMarshal ¶
YamlMarshal wrapper for yaml.Marshal.
func YamlUnmarshal ¶
YamlUnmarshal wrapper for yaml.Unmarshal or yaml.UnmarshalStrict, if type of out is map[string]interface{}, *map[string]interface{}, the inner map[interface{}]interface{} will fix to map[string]interface{} recursively. if type of out is *interface{}, the underlying type of out will change to *map[string]interface{}.
Types ¶
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")