aboutsummaryrefslogtreecommitdiff
path: root/plugin/pkg/uniq/uniq.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/pkg/uniq/uniq.go')
-rw-r--r--plugin/pkg/uniq/uniq.go17
1 files changed, 6 insertions, 11 deletions
diff --git a/plugin/pkg/uniq/uniq.go b/plugin/pkg/uniq/uniq.go
index f4b4f54a6..c3fdb5211 100644
--- a/plugin/pkg/uniq/uniq.go
+++ b/plugin/pkg/uniq/uniq.go
@@ -10,27 +10,22 @@ type U struct {
type item struct {
state int // either todo or done
f func() error // function to be executed.
- obj interface{} // any object to return when needed
}
// New returns a new initialized U.
func New() U { return U{u: make(map[string]item)} }
-// Set sets function f in U under key. If the key already exists
-// it is not overwritten.
-func (u U) Set(key string, f func() error, o interface{}) interface{} {
- if item, ok := u.u[key]; ok {
- return item.obj
+// Set sets function f in U under key. If the key already exists it is not overwritten.
+func (u U) Set(key string, f func() error) {
+ if _, ok := u.u[key]; ok {
+ return
}
- u.u[key] = item{todo, f, o}
- return o
+ u.u[key] = item{todo, f}
}
// Unset removes the key.
func (u U) Unset(key string) {
- if _, ok := u.u[key]; ok {
- delete(u.u, key)
- }
+ delete(u.u, key)
}
// ForEach iterates for u executes f for each element that is 'todo' and sets it to 'done'.