Documentation ¶
Index ¶
- func EveryNil(elems ...any) bool
- func Pull[V comparable](collection []V, elements ...V) []V
- func PullAt[V any](collection []V, indices ...int) []V
- func Remove[V comparable](collection []V, predicate func(V, int) bool) []V
- func SomeNil(elems ...any) bool
- func Split[T comparable](collection []T, isSeparator func(T, int) bool) [][]T
- func SplitStr(str string, separators ...rune) []string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EveryNil ¶ added in v1.0.11
Example ¶
ExampleEveryNil is an example function.
package main import ( "fmt" "github.com/xuender/kit/los" ) func main() { fmt.Println(los.EveryNil(nil, nil)) fmt.Println(los.EveryNil(nil, 1)) }
Output: true false
func Pull ¶
func Pull[V comparable](collection []V, elements ...V) []V
Pull 删除切片指定成员.
Example ¶
ExamplePull is an example function.
package main import ( "fmt" "github.com/xuender/kit/los" ) func main() { fmt.Println(los.Pull([]int{1, 2, 2, 3}, 0, 2)) }
Output: [1 3]
func PullAt ¶
PullAt 删除切片指定位置.
Example ¶
ExamplePullAt is an example function.
package main import ( "fmt" "github.com/xuender/kit/los" ) func main() { fmt.Println(los.PullAt([]rune{'1', '2', '2', '3'}, 2, 3)) }
Output: [49 50]
func Remove ¶
func Remove[V comparable](collection []V, predicate func(V, int) bool) []V
Remove 根据断言删除.
Example ¶
ExampleRemove is an example function.
package main import ( "fmt" "github.com/xuender/kit/los" ) func main() { fmt.Println(los.Remove([]int{1, 2, 2, 3, 4}, func(item, _ int) bool { return item%2 == 0 })) }
Output: [1 3]
func SomeNil ¶ added in v1.0.11
Example ¶
ExampleSomeNil is an example function.
package main import ( "fmt" "github.com/xuender/kit/los" ) func main() { fmt.Println(los.SomeNil(nil, 1)) fmt.Println(los.SomeNil(1, 2)) }
Output: true false
func Split ¶
func Split[T comparable](collection []T, isSeparator func(T, int) bool) [][]T
Split 切片分解.
Example ¶
ExampleSplit is an example function.
package main import ( "fmt" "github.com/xuender/kit/los" ) func main() { fmt.Println(los.Split( []int{1, 0, 2, 3, 0, 4, 0, 5}, func(num, _ int) bool { return num == 0 }, )) }
Output: [[1] [2 3] [4] [5]]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.