Documentation ¶
Index ¶
- func CopySlicInt(src []int) []int
- func DeepClone(v interface{}) interface{}
- func DeepCopy(dst, src interface{})
- func DesDecrypt(bstr, key []byte) ([]byte, error)
- func DesEncrypt(src, key []byte) ([]byte, error)
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func RandGroup(p ...uint32) int
- func RandInterval(b1, b2 int) int
- func RandIntervalN(b1, b2 int32, n uint32) []int32
- func ZeroPadding(ciphertext []byte, blockSize int) []byte
- func ZeroUnPadding(origData []byte) []byte
- type Map
- func (m *Map) Del(key interface{})
- func (m *Map) Get(key interface{}) interface{}
- func (m *Map) Len() int
- func (m *Map) LockRange(f func(interface{}, interface{}))
- func (m *Map) RLockRange(f func(interface{}, interface{}))
- func (m *Map) Set(key interface{}, value interface{})
- func (m *Map) TestAndSet(key interface{}, value interface{}) interface{}
- func (m *Map) UnsafeDel(key interface{})
- func (m *Map) UnsafeGet(key interface{}) interface{}
- func (m *Map) UnsafeLen() int
- func (m *Map) UnsafeRange(f func(interface{}, interface{}))
- func (m *Map) UnsafeSet(key interface{}, value interface{})
- type Semaphore
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopySlicInt ¶
func DeepClone ¶
func DeepClone(v interface{}) interface{}
Example ¶
package main import ( "fmt" "github.com/lovelly/leaf/util" ) func main() { src := []int{1, 2, 3} dst := util.DeepClone(src).([]int) for _, v := range dst { fmt.Println(v) } }
Output: 1 2 3
func DeepCopy ¶
func DeepCopy(dst, src interface{})
Example ¶
package main import ( "fmt" "github.com/lovelly/leaf/util" ) func main() { src := []int{1, 2, 3} var dst []int util.DeepCopy(&dst, &src) for _, v := range dst { fmt.Println(v) } }
Output: 1 2 3
func DesDecrypt ¶
func DesEncrypt ¶
func PKCS5Padding ¶
func PKCS5UnPadding ¶
func RandGroup ¶
Example ¶
package main import ( "fmt" "github.com/lovelly/leaf/util" ) func main() { i := util.RandGroup(0, 0, 50, 50) switch i { case 2, 3: fmt.Println("ok") } }
Output: ok
func RandInterval ¶
Example ¶
package main import ( "fmt" "github.com/lovelly/leaf/util" ) func main() { v := util.RandInterval(-1, 1) switch v { case -1, 0, 1: fmt.Println("ok") } }
Output: ok
func RandIntervalN ¶
Example ¶
package main import ( "fmt" "github.com/lovelly/leaf/util" ) func main() { r := util.RandIntervalN(-1, 0, 2) if r[0] == -1 && r[1] == 0 || r[0] == 0 && r[1] == -1 { fmt.Println("ok") } }
Output: ok
func ZeroPadding ¶
func ZeroUnPadding ¶
Types ¶
type Map ¶
Example ¶
package main import ( "fmt" "github.com/lovelly/leaf/util" ) func main() { m := new(util.Map) fmt.Println(m.Get("key")) m.Set("key", "value") fmt.Println(m.Get("key")) m.Del("key") fmt.Println(m.Get("key")) m.Set(1, "1") m.Set(2, 2) m.Set("3", 3) fmt.Println(m.Len()) }
Output: <nil> value <nil> 3
func (*Map) RLockRange ¶
func (m *Map) RLockRange(f func(interface{}, interface{}))
func (*Map) TestAndSet ¶
func (m *Map) TestAndSet(key interface{}, value interface{}) interface{}
func (*Map) UnsafeRange ¶
func (m *Map) UnsafeRange(f func(interface{}, interface{}))
Click to show internal directories.
Click to hide internal directories.