Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event/*: golint updates for this or self warning #16631

Merged
merged 3 commits into from
May 3, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions event/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,37 @@ func New() *Filters {
}
}

func (self *Filters) Start() {
go self.loop()
func (f *Filters) Start() {
go f.loop()
}

func (self *Filters) Stop() {
close(self.quit)
func (f *Filters) Stop() {
close(f.quit)
}

func (self *Filters) Notify(filter Filter, data interface{}) {
self.ch <- FilterEvent{filter, data}
func (f *Filters) Notify(filter Filter, data interface{}) {
f.ch <- FilterEvent{filter, data}
}

func (self *Filters) Install(watcher Filter) int {
self.watchers[self.id] = watcher
self.id++
func (f *Filters) Install(watcher Filter) int {
f.watchers[self.id] = watcher
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to replace self.id here.

f.id++

return self.id - 1
return f.id - 1
}

func (self *Filters) Uninstall(id int) {
delete(self.watchers, id)
func (f *Filters) Uninstall(id int) {
delete(f.watchers, id)
}

func (self *Filters) loop() {
func (f *Filters) loop() {
out:
for {
select {
case <-self.quit:
case <-f.quit:
break out
case event := <-self.ch:
for _, watcher := range self.watchers {
case event := <-f.ch:
for _, watcher := range f.watchers {
if reflect.TypeOf(watcher) == reflect.TypeOf(event.filter) {
if watcher.Compare(event.filter) {
watcher.Trigger(event.data)
Expand All @@ -86,10 +86,10 @@ out:
}
}

func (self *Filters) Match(a, b Filter) bool {
func (f *Filters) Match(a, b Filter) bool {
return reflect.TypeOf(a) == reflect.TypeOf(b) && a.Compare(b)
}

func (self *Filters) Get(i int) Filter {
return self.watchers[i]
func (f *Filters) Get(i int) Filter {
return f.watchers[i]
}