util

package
v0.0.0-...-37d5b15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepClone

func DeepClone(v interface{}) interface{}
Example
package main

import (
	"fmt"
	"github.com/name5566/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/name5566/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

Types

type Map

type Map struct {
	sync.RWMutex
	// contains filtered or unexported fields
}
Example
package main

import (
	"fmt"
	"github.com/name5566/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) Del

func (m *Map) Del(key interface{})

func (*Map) Get

func (m *Map) Get(key interface{}) interface{}

func (*Map) Len

func (m *Map) Len() int

func (*Map) LockRange

func (m *Map) LockRange(f func(interface{}, interface{}))

func (*Map) RLockRange

func (m *Map) RLockRange(f func(interface{}, interface{}))

func (*Map) Set

func (m *Map) Set(key interface{}, value interface{})

func (*Map) TestAndSet

func (m *Map) TestAndSet(key interface{}, value interface{}) interface{}

func (*Map) UnsafeDel

func (m *Map) UnsafeDel(key interface{})

func (*Map) UnsafeGet

func (m *Map) UnsafeGet(key interface{}) interface{}

func (*Map) UnsafeLen

func (m *Map) UnsafeLen() int

func (*Map) UnsafeRange

func (m *Map) UnsafeRange(f func(interface{}, interface{}))

func (*Map) UnsafeSet

func (m *Map) UnsafeSet(key interface{}, value interface{})

type Semaphore

type Semaphore chan struct{}

func MakeSemaphore

func MakeSemaphore(n int) Semaphore

func (Semaphore) Acquire

func (s Semaphore) Acquire()

func (Semaphore) Release

func (s Semaphore) Release()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL