From 1c8e48305a43b3ebe84d2c046ba1da31d70284a8 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 15 Jun 2023 12:29:11 +0200 Subject: pkg/report: refactor Type Make it string -- it will be easier and cause less code duplication. --- pkg/report/report.go | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'pkg') diff --git a/pkg/report/report.go b/pkg/report/report.go index ca0fe575c..ebbcd894c 100644 --- a/pkg/report/report.go +++ b/pkg/report/report.go @@ -75,31 +75,18 @@ func (r Report) String() string { return fmt.Sprintf("crash: %v\n%s", r.Title, r.Report) } -type Type int +type Type string const ( - Unknown Type = iota - Hang - MemoryLeak - DataRace - UnexpectedReboot + Unknown = Type("") + Hang = Type("HANG") + MemoryLeak = Type("LEAK") + DataRace = Type("DATARACE") + UnexpectedReboot = Type("REBOOT") ) func (t Type) String() string { - switch t { - case Unknown: - return "UNKNOWN" - case Hang: - return "HANG" - case MemoryLeak: - return "LEAK" - case DataRace: - return "DATARACE" - case UnexpectedReboot: - return "REBOOT" - default: - panic("unknown report type") - } + return string(t) } // NewReporter creates reporter for the specified OS/Type. -- cgit mrf-deployment