clair/vendor/github.com/deckarep/golang-set/iterator_example_test.go
Sida Chen 34d0e516e0 vendor: Add golang-set dependency
Golang-set library is added to make it easier to support set operations.
2018-10-08 10:42:40 -04:00

33 lines
477 B
Go

package mapset
import (
"fmt"
)
type YourType struct {
Name string
}
func ExampleIterator() {
set := NewSetFromSlice([]interface{}{
&YourType{Name: "Alise"},
&YourType{Name: "Bob"},
&YourType{Name: "John"},
&YourType{Name: "Nick"},
})
var found *YourType
it := set.Iterator()
for elem := range it.C {
if elem.(*YourType).Name == "John" {
found = elem.(*YourType)
it.Stop()
}
}
fmt.Printf("Found %+v\n", found)
// Output: Found &{Name:John}
}