gtx


Branch: develop

Author
Sotiri Bakagiannis <thewhodidthis@users.noreply.github.com>
Date
Nov. 17 '22 13:52:00
Commit
bade45779752e9abb9fd457d86895f0225b4f11b
Parent
be6415bc0176fd55d024b452f93b50c99475777a
Changes
diff --git a/main.go b/main.go
index e27c115..4ed7342 100644
--- a/main.go
+++ b/main.go
@@ -25,9 +25,11 @@ var iTmpl string
 // https://stackoverflow.com/questions/28322997/how-to-get-a-list-of-values-into-a-flag-in-golang/
 type bflag []string
 
-// TODO: Make sure these are unique.
 func (b *bflag) Set(value string) error {
-	*b = append(*b, value)
+	// Make sure there are no duplicates.
+	if !includes(*b, value) {
+		*b = append(*b, value)
+	}
 
 	return nil
 }
@@ -684,3 +686,14 @@ func htmlFooter() {
 	   }
 	*/
 }
+
+// Helps decide if value contained in slice.
+func includes(s []string, n string) bool {
+	for _, v := range s {
+		if v == n {
+			return true
+		}
+	}
+
+	return false
+}