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

889 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
CutSuffix cutsuffix slice.go#L821 core slice https://go.dev/play/p/7FKfBFvPTaT
core#slice#cutsuffix
core#slice#cutprefix
core#slice#cut
core#slice#trimsuffix
core#slice#trimright
core#slice#slice
core#slice#dropright
core#slice#hassuffix
0
func CutSuffix[T comparable, Slice ~[]T](collection Slice, separator Slice) (before Slice, found bool)

Returns the collection without the provided trailing suffix and a boolean indicating whether it was present.

left, found := lo.CutSuffix([]string{"a", "b", "c", "d", "e", "f", "g"}, []string{"f", "g"})
// left: []string{"a", "b", "c", "d", "e"}
// found: true

left, found = lo.CutSuffix([]string{"a", "b", "c"}, []string{"b"})
// left: []string{"a", "b", "c"}
// found: false