MCPcopy
hub / github.com/duke-git/lancet / Concat

Function Concat

strutil/string.go:654–670  ·  view source on GitHub ↗

Concat uses the strings.Builder to concatenate the input strings. - `length` is the expected length of the concatenated string. - if you are unsure about the length of the string to be concatenated, please pass 0 or a negative number. Play: https://go.dev/play/p/gD52SZHr4Kp

(length int, str ...string)

Source from the content-addressed store, hash-verified

652//
653// Play: https://go.dev/play/p/gD52SZHr4Kp
654func Concat(length int, str ...string) string {
655 if len(str) == 0 {
656 return ""
657 }
658
659 sb := strings.Builder{}
660 if length <= 0 {
661 sb.Grow(len(str[0]) * len(str))
662 } else {
663 sb.Grow(length)
664 }
665
666 for _, s := range str {
667 sb.WriteString(s)
668 }
669 return sb.String()
670}
671
672// Ellipsis truncates a string to a specified length and appends an ellipsis.
673// Play: https://go.dev/play/p/i1vbdQiQVRR

Callers 2

TestConcatFunction · 0.70
ExampleConcatFunction · 0.70

Calls 1

StringMethod · 0.65

Tested by 2

TestConcatFunction · 0.56
ExampleConcatFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…