vbantxt/util.go

24 lines
366 B
Go
Raw Normal View History

2022-11-05 18:58:36 +00:00
package main
import "flag"
2022-11-05 18:58:36 +00:00
// indexOf returns the index of an element in an array
func indexOf[T comparable](collection []T, e T) int {
for i, x := range collection {
if x == e {
return i
}
}
return -1
}
func isFlagPassed(name string) bool {
found := false
flag.Visit(func(f *flag.Flag) {
if f.Name == name {
found = true
}
})
return found
}