MCPcopy
hub / github.com/zeromicro/go-zero / Join

Function Join

core/stringx/strings.go:67–89  ·  view source on GitHub ↗

Join joins any number of elements into a single string, separating them with given sep. Empty elements are ignored. However, if the argument list is empty or all its elements are empty, Join returns an empty string.

(sep byte, elem ...string)

Source from the content-addressed store, hash-verified

65// Empty elements are ignored. However, if the argument list is empty or all its elements are empty,
66// Join returns an empty string.
67func Join(sep byte, elem ...string) string {
68 var size int
69 for _, e := range elem {
70 size += len(e)
71 }
72 if size == 0 {
73 return ""
74 }
75
76 buf := make([]byte, 0, size+len(elem)-1)
77 for _, e := range elem {
78 if len(e) == 0 {
79 continue
80 }
81
82 if len(buf) > 0 {
83 buf = append(buf, sep)
84 }
85 buf = append(buf, e...)
86 }
87
88 return string(buf)
89}
90
91// NotEmpty checks if all strings are not empty in args.
92func NotEmpty(args ...string) bool {

Callers 1

TestJoinFunction · 0.70

Calls

no outgoing calls

Tested by 1

TestJoinFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…