Files
lo/docs/data/core-trim.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

654 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
Trim trim slice.go#L842 core slice https://go.dev/play/p/LZLfLj5C8Lg
core#slice#trim
core#slice#trimleft
core#slice#trimright
core#slice#trimprefix
core#slice#trimsuffix
0
func Trim[T comparable, Slice ~[]T](collection Slice, cutset Slice) Slice

Removes all leading and trailing elements in the cutset from the collection.

result := lo.Trim([]int{0, 1, 2, 0, 3, 0}, []int{1, 0})
// []int{2, 0, 3}

result = lo.Trim([]string{"hello", "world", " "}, []string{" ", ""})
// []string{"hello", "world"}