Files
lo/docs/data/core-trimprefix.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

709 B

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

Removes all leading occurrences of the given prefix from the collection.

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

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