From f63e065d16018e956cd17d8a56881c537b56d9ff Mon Sep 17 00:00:00 2001 From: "oleg.merkulov" Date: Thu, 31 Oct 2019 12:36:32 +0100 Subject: [PATCH 1/2] Introduce Scanner interface as an abstraction for Clamd struct --- clamd.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/clamd.go b/clamd.go index 5199f63..509e267 100644 --- a/clamd.go +++ b/clamd.go @@ -40,6 +40,20 @@ const ( RES_PARSE_ERROR = "PARSE ERROR" ) +type Scanner interface { + Ping() error + Version() (chan *ScanResult, error) + Stats() (*Stats, error) + Reload() error + Shutdown() error + ScanFile(path string) (chan *ScanResult, error) + RawScanFile(path string) (chan *ScanResult, error) + MultiScanFile(path string) (chan *ScanResult, error) + ContScanFile(path string) (chan *ScanResult, error) + AllMatchScanFile(path string) (chan *ScanResult, error) + ScanStream(r io.Reader, abort chan bool) (chan *ScanResult, error) +} + type Clamd struct { address string } From 2182da3f560fe03a1e9822cd1a2fa07401423f70 Mon Sep 17 00:00:00 2001 From: "oleg.merkulov" Date: Thu, 31 Oct 2019 14:11:48 +0100 Subject: [PATCH 2/2] Add Scanner to a response of NewClamd --- clamd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clamd.go b/clamd.go index 509e267..cda83bc 100644 --- a/clamd.go +++ b/clamd.go @@ -319,7 +319,7 @@ func (c *Clamd) ScanStream(r io.Reader, abort chan bool) (chan *ScanResult, erro return ch, nil } -func NewClamd(address string) *Clamd { +func NewClamd(address string) Scanner { clamd := &Clamd{address: address} return clamd }