From de040344f89656862b5bbd306b8a9c143dae3dea Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Mon, 2 Aug 2021 17:08:58 +0000 Subject: pkg/report: separate reporter wrapper from OS-specific implementations Currently a number of report post-processing activities are implemented as a decorator over the interface that defines OS-specific implementations. Following exactly the same interface is too restrictive in this case as adding extra parameters to the post-processing forces the developer to adjust all implementations thay may not need these parameters at all. Untie the wrapper from the Reporter interface. Use a package-private reporterImpl interface for the OS-specific implementations, while having an exported Reporter structure. Make sure that Reporter is stored and passed as a pointer. --- pkg/report/fuzz.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg/report/fuzz.go') diff --git a/pkg/report/fuzz.go b/pkg/report/fuzz.go index 8952baf76..2e747929a 100644 --- a/pkg/report/fuzz.go +++ b/pkg/report/fuzz.go @@ -13,7 +13,7 @@ import ( func Fuzz(data []byte) int { res := 0 for os, reporter := range fuzzReporters { - typ := reporter.(*reporterWrapper).typ + typ := reporter.typ containsCrash := reporter.ContainsCrash(data) rep := reporter.Parse(data) if containsCrash != (rep != nil) { @@ -64,8 +64,8 @@ func Fuzz(data []byte) int { return res } -var fuzzReporters = func() map[string]Reporter { - reporters := make(map[string]Reporter) +var fuzzReporters = func() map[string]*Reporter { + reporters := make(map[string]*Reporter) for os := range ctors { if os == targets.Windows { continue @@ -80,7 +80,7 @@ var fuzzReporters = func() map[string]Reporter { if err != nil { panic(err) } - if _, ok := reporter.(*stub); ok { + if _, ok := reporter.impl.(*stub); ok { continue } reporters[os] = reporter -- cgit mrf-deployment