通过map实现
package main
import "fmt"
func main() {
hashSet:= make(map[string]struct{})
hashSet["abc"] = struct{}{}
hashSet["abcd"] = struct{}{}
for key, _ := range hashSet {
fmt.Println(key)
}
}
输出结果为:
abc
abcd