From 48a763a90c557f1cdec8fae0287c0792a0dda5e7 Mon Sep 17 00:00:00 2001 From: Julien Riou Date: Thu, 20 May 2021 17:07:56 +0200 Subject: [PATCH] style: add comments on filters Signed-off-by: Julien Riou --- filter_exclude.go | 4 +++- filter_include.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/filter_exclude.go b/filter_exclude.go index 3aa1ae3..765ef7a 100644 --- a/filter_exclude.go +++ b/filter_exclude.go @@ -6,10 +6,12 @@ import ( log "github.com/sirupsen/logrus" ) +// ExcludeFilter struct to store the compiled regex used for the exclusion type ExcludeFilter struct { regex *regexp.Regexp } +// NewExcludeFilter to create an ExcludeFilter func NewExcludeFilter(regex string) (*ExcludeFilter, error) { var err error var compiledRegex *regexp.Regexp @@ -25,7 +27,7 @@ func NewExcludeFilter(regex string) (*ExcludeFilter, error) { return &ExcludeFilter{regex: compiledRegex}, nil } -// Filter excludes product with name matching the regex +// Include returns false when the product name matches the regex // implements the Filter interface func (f *ExcludeFilter) Include(product *Product) bool { if f.regex == nil { diff --git a/filter_include.go b/filter_include.go index 1d45aa1..520d6e3 100644 --- a/filter_include.go +++ b/filter_include.go @@ -6,10 +6,12 @@ import ( log "github.com/sirupsen/logrus" ) +// IncludeFilter struct to store the compiled regex used for the inclusion type IncludeFilter struct { regex *regexp.Regexp } +// NewIncludeFilter to create an IncludeFilter func NewIncludeFilter(regex string) (*IncludeFilter, error) { var err error var compiledRegex *regexp.Regexp @@ -25,7 +27,7 @@ func NewIncludeFilter(regex string) (*IncludeFilter, error) { return &IncludeFilter{regex: compiledRegex}, nil } -// Filter includes product with name matching the regex +// Include returns treue when the product name matches the regex // implements the Filter interface func (f *IncludeFilter) Include(product *Product) bool { if f.regex == nil {