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

855 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
CutPrefix cutprefix slice.go#L800 core slice https://go.dev/play/p/P1scQj53aFa
core#slice#cutprefix
core#slice#cutsuffix
core#slice#cut
core#slice#trimprefix
core#slice#trimleft
core#slice#slice
core#slice#drop
core#slice#hasprefix
0
func CutPrefix[T comparable, Slice ~[]T](collection Slice, separator Slice) (after Slice, found bool)

Returns the collection without the provided leading prefix and a boolean indicating whether it was present.

right, found := lo.CutPrefix([]string{"a", "b", "c", "d"}, []string{"a", "b", "c"})
// right: []string{"d"}
// found: true

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