Files
lo/docs/data/core-ellipsis.md
T
2026-02-22 05:20:42 +01:00

869 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
Ellipsis ellipsis string.go#L235 core string https://go.dev/play/p/qE93rgqe1TW
core#string#ellipsis
core#string#substring
core#string#runelength
core#string#trim
core#string#capitalize
100
func Ellipsis(str string, length int) string

Trims and truncates a string to the specified length in runes (Unicode code points) and appends an ellipsis if truncated. Multi-byte characters such as emoji or CJK ideographs are never split in the middle.

lo.Ellipsis("  Lorem Ipsum  ", 5)
// "Lo..."

str = lo.Ellipsis("Lorem Ipsum", 100)
// "Lorem Ipsum"

str = lo.Ellipsis("Lorem Ipsum", 3)
// "..."

str = lo.Ellipsis("hello 世界! 你好", 8)
// "hello..."

str = lo.Ellipsis("🏠🐶🐱🌟", 4)
// "🏠🐶🐱🌟"