fix: validate that parameter names are unique (#7882)

This commit is contained in:
Asher
2023-06-07 09:44:50 -08:00
committed by GitHub
parent fbdbc8a6c5
commit 125e9ef00e
4 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package strings
import (
"fmt"
"strings"
)
// JoinWithConjunction joins a slice of strings with commas except for the last
// two which are joined with "and".
func JoinWithConjunction(s []string) string {
last := len(s) - 1
if last == 0 {
return s[last]
}
return fmt.Sprintf("%s and %s",
strings.Join(s[:last], ", "),
s[last],
)
}