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() +}
home › develop › 3507157 › 185f1a5