How to Check If a Slice Contains an Element in Go
The Go 1.21 stable release in August 2023
introduced a new slices
package, featuring generic functions applicable to any
slice type. A key function, Contains()
, checks for the presence of an element
in a slice: