diff options
author | Alexander Neumann <an2048@googlemail.com> | 2012-02-20 19:32:07 +0100 |
---|---|---|
committer | Alexander Neumann <an2048@googlemail.com> | 2012-02-20 19:32:07 +0100 |
commit | 8f5a1176964a711a6394c08f454a5914d3175ccc (patch) | |
tree | b2fa0ab602671545638e126258e9459a17cce87a /closeevent.go | |
parent | Remove printing support (diff) | |
download | wireguard-windows-8f5a1176964a711a6394c08f454a5914d3175ccc.tar.xz wireguard-windows-8f5a1176964a711a6394c08f454a5914d3175ccc.zip |
Run go fix; apply additional manual fixes
Diffstat (limited to 'closeevent.go')
-rw-r--r-- | closeevent.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/closeevent.go b/closeevent.go index 620b5743..34843b57 100644 --- a/closeevent.go +++ b/closeevent.go @@ -10,17 +10,13 @@ type CloseEvent struct { handlers []CloseEventHandler } -func (e *CloseEvent) Attach(handler CloseEventHandler) { +func (e *CloseEvent) Attach(handler CloseEventHandler) int { e.handlers = append(e.handlers, handler) + return len(e.handlers) - 1 } -func (e *CloseEvent) Detach(handler CloseEventHandler) { - for i, h := range e.handlers { - if h == handler { - e.handlers = append(e.handlers[:i], e.handlers[i+1:]...) - return - } - } +func (e *CloseEvent) Detach(handle int) { + e.handlers = append(e.handlers[:handle], e.handlers[handle+1:]...) } type CloseEventPublisher struct { |