mirror of
https://github.com/photoprism/photoprism.git
synced 2026-01-23 02:24:24 +00:00
15 lines
279 B
Go
15 lines
279 B
Go
package list
|
|
|
|
// Add adds a string to the list if it does not exist yet.
|
|
func Add(list []string, s string) []string {
|
|
switch {
|
|
case s == "":
|
|
return list
|
|
case len(list) == 0:
|
|
return []string{s}
|
|
case Contains(list, s):
|
|
return list
|
|
default:
|
|
return append(list, s)
|
|
}
|
|
}
|