Why is there no built-in set data structure in Go and how to implement it?
Hi everyone! I'm new to Go, coming from Python, and I'm really confused by the lack of a built-in set data type. In Python, I constantly used set for fast uniqueness checks, removing duplicates from slices, and checking intersections. For example:
```go
// How do I do this in Go?
uniqueNames := []string{}
seen := set() // This doesn't exist!
for _, name := range names {
if !seen.Contains(name) {
seen.Add(name)
uniqueNames = append(uniqueNames, name)
}
}
```
I understand that you can use map[string]bool or map[string]struct{}, but this feels like a workaround. Why didn't the Go developers add a proper set to the standard library? It's a basic data structure that exists in almost all modern languages.
Maybe