From 9a6a7617b4086816a7e58ee8a4f520b1ba7f936c Mon Sep 17 00:00:00 2001 From: chris <331548+cristoper@users.noreply.github.com> Date: Sat, 18 Feb 2023 13:02:57 -0700 Subject: [PATCH] PrettyPrint should conform to Exporter interface `(*PrettyPrint) Export()` needs to return error in order to conform to the `Exporter` interface and be used as an exporter. Without this change, trying to use the PrettyPrint exporter results in this compile error: cannot use &export.PrettyPrint{} (value of type *export.PrettyPrint) as type export.Exporter in array or slice literal: *export.PrettyPrint does not implement export.Exporter (wrong type for Export method) have Export(exports chan interface{}) want Export(exports chan interface{}) error --- export/pprint.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/export/pprint.go b/export/pprint.go index 811c05d..5e369d6 100644 --- a/export/pprint.go +++ b/export/pprint.go @@ -9,7 +9,7 @@ import ( type PrettyPrint struct{} // Export logs exported data to console as pretty printed -func (*PrettyPrint) Export(exports chan interface{}) { +func (*PrettyPrint) Export(exports chan interface{}) error { for res := range exports { dat, err := json.MarshalIndent(res, "", " ") if err != nil { @@ -17,4 +17,5 @@ func (*PrettyPrint) Export(exports chan interface{}) { } fmt.Println(string(dat)) } + return nil }