photoprism/pkg/list/add.go
Michael Mayer 149f5e5731 CI: Apply Go linter recommendations to remaining "pkg/..." code #5330
Signed-off-by: Michael Mayer <michael@photoprism.app>
2025-11-22 16:14:43 +01:00

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)
}
}