Linear search through a slice is almost always going to be faster than a map operation, because N is almost always small and slices have great cache locality.
If your slice has a million entries, it's definitely a different story.
Using a map might not be faster as others have pointed out, but it's often more readable. The core library does this in several places. A map[someType]bool makes for nice, readable code:
SergeAx|4 years ago
omginternets|4 years ago
If your slice has a million entries, it's definitely a different story.
jniedrauer|4 years ago
grogenaut|4 years ago
inertiatic|4 years ago