欢迎来到cool的博客
7

Music box

Click to Start

点击头像播放音乐
新博客链接

Golang中对 slice 处理的一些方法

beego的utils里面基本上实现了slice的全部操作:

  • func InSlice(v string, sl []string) bool
  • func InSliceIface(v interface{}, sl []interface{}) bool
  • func SliceChunk(slice []interface{}, size int) (chunkslice [][]interface{})
  • func SliceDiff(slice1, slice2 []interface{}) (diffslice []interface{})
  • func SliceFilter(slice []interface{}, a filtertype) (ftslice []interface{})
  • func SliceIntersect(slice1, slice2 []interface{}) (diffslice []interface{})
  • func SliceMerge(slice1, slice2 []interface{}) (c []interface{})
  • func SlicePad(slice []interface{}, size int, val interface{}) []interface{}
  • func SliceRand(a []interface{}) (b interface{})
  • func SliceRandList(min, max int) []int
  • func SliceRange(start, end, step int64) (intslice []int64)
  • func SliceReduce(slice []interface{}, a reducetype) (dslice []interface{})
  • func SliceShuffle(slice []interface{}) []interface{}
  • func SliceSum(intslice []int64) (sum int64)
  • func SliceUnique(slice []interface{}) (uniqueslice []interface{})

https://github.com/astaxie/beego/blob/master/utils/slice.go

返回列表