1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/pkg/utils/strings/join.go
Jim Bugwadia f287e0a220
Conditions message (#7113)
* add message to conditions

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* add tests

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* extend tests

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

---------

Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2023-05-08 15:34:23 +08:00

20 lines
287 B
Go

package strings
import "strings"
func JoinNonEmpty(elems []string, sep string) string {
var bldr strings.Builder
var idx int = 0
for _, s := range elems {
if s != "" {
if idx > 0 {
bldr.WriteString(sep)
}
bldr.WriteString(s)
idx++
}
}
return bldr.String()
}