Skip to content

Instantly share code, notes, and snippets.

@prasad83
Forked from kn9ts/in_array.go
Last active January 3, 2021 18:25
Show Gist options
  • Save prasad83/dc88f7c1a8534af33d0ae020967d47de to your computer and use it in GitHub Desktop.
Save prasad83/dc88f7c1a8534af33d0ae020967d47de to your computer and use it in GitHub Desktop.
// Function to check if the the string given is in the array
inArray := func(str string, list []string) bool {
// early exit if list is nil
if list == nil {
return false
}
for _, v := range list {
if v == str {
return true
}
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment