Copyright 2019 by Shawn Rupp
simpleset provides a straightforward set similar to a python set. It supports string, integer, and float64 based sets. It does not support mixed-type sets, so, for example, you cannot add an integer to a string set.
go get github.com/icwells/simpleset
To make a new empty set, either call the appropriate constructor for the type you want the set to hold. To convert a slice of strings, integers, or float64s, pass the slice to ToSet which will return a set of the appropriate type.
letters := []string{"a", "b", "c", "d", "e"}
set := simpleset.NewStringSet()
for _, i := range letters {
// Can also pass the whole slice to Extend
set.Add(i)
}
For documentation on additional methods, follow the GoDocs link above.