cherryUtils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 19 Imported by: 16

Documentation

Overview

file from https://github.com/beego/beego/blob/develop/core/utils/slice.go

Index

Constants

This section is empty.

Variables

View Source
var (
	Compress = &compress{}
	Crypto   = &crypto{}
	File     = &file{}
	Reflect  = &reflection{}
	Timer    = &timer{}
	Strings  = &strings{}
	Json     = &json{}
	Net      = &net{}
	Slice    = &slice{}
)

Functions

func Chunk

func Chunk(slice []interface{}, size int) (chunkSlice [][]interface{})

Chunk separates one slice to some sized slice.

func Diff

func Diff(slice1, slice2 []interface{}) (diffSlice []interface{})

Diff returns diff slice of slice1 - slice2.

func Error

func Error(text string) error

func Errorf

func Errorf(format string, a ...interface{}) error

func Filter

func Filter(slice []interface{}, a func(interface{}) bool) (filterSlice []interface{})

Filter generates a new slice after filter function.

func InInterface

func InInterface(v interface{}, sl []interface{}) bool

InInterface checks given interface in interface slice.

func Intersect

func Intersect(slice1, slice2 []interface{}) (diffSlice []interface{})

Intersect returns slice that are present in all the slice1 and slice2.

func Merge

func Merge(slice1, slice2 []interface{}) (c []interface{})

Merge merges interface slices to one slice.

func Pad

func Pad(slice []interface{}, size int, val interface{}) []interface{}

Pad prepends size number of val into slice.

func Rand

func Rand(a []interface{}) (b interface{})

SliceRand returns random one from slice.

func RandList

func RandList(min, max int) []int

RandList generate an int slice from min to max.

func Range

func Range(start, end, step int64) (intSlice []int64)

Range generates a new slice from begin to end with step duration of int64 number.

func Reduce

func Reduce(slice []interface{}, a func(interface{}) interface{}) (destSlice []interface{})

Reduce generates a new slice after parsing every value by reduce function

func Shuffle

func Shuffle(slice []interface{}) []interface{}

Shuffle shuffles a slice.

func Sum

func Sum(intslice []int64) (sum int64)

Sum sums all values in int64 slice.

func Unique

func Unique(slice []interface{}) (uniqueSlice []interface{})

Unique cleans repeated values in slice.

Types

type WaitGroup

type WaitGroup struct {
	// contains filtered or unexported fields
}

WaitGroup 封装 sync.WaitGroup,提供更简单的 API

func (*WaitGroup) Add

func (wg *WaitGroup) Add(fn func())

Add 添加一个非阻塞的任务,任务在新的 Go 程执行

func (*WaitGroup) Wait

func (wg *WaitGroup) Wait()

Wait 等待所有任务执行完成

Jump to

Keyboard shortcuts

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