gtx


Branch: develop

Author
thewhodidthis <thewhodidthis@fastmail.com>
Date
Nov. 24 '22 18:55:22
Commit
185f1a5e1f7c8d1091bfb379ec840e1843a580c7
Parent
3507157dd9c914b8aadf42b267a99638d5537647
Changes
diff --git a/helper.go b/helper.go
new file mode 100644
index 0000000..9041dff
--- /dev/null
+++ b/helper.go
@@ -0,0 +1,29 @@
+package main
+
+import "reflect"
+
+type void struct{}
+
+// Helps decide if value contained in slice.
+// https://stackoverflow.com/questions/38654383/how-to-search-for-an-element-in-a-golang-slice
+func contains(s []string, n string) bool {
+	for _, v := range s {
+		if v == n {
+			return true
+		}
+	}
+
+	return false
+}
+
+// Helps clear duplicates in slice.
+// https://stackoverflow.com/questions/66643946/how-to-remove-duplicates-strings-or-int-from-slice-in-go
+func dedupe(input []string) []reflect.Value {
+	set := make(map[string]void)
+
+	for _, v := range input {
+		set[v] = void{}
+	}
+
+	return reflect.ValueOf(set).MapKeys()
+}