Files
lo/docs/data/core-trimsuffix.md
T
2025-10-06 17:15:49 +02:00

716 B

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

Removes all trailing occurrences of the given suffix from the collection.

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

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