From 006b8325749f361e1826c3a46304a8f161cfb83d Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Thu, 6 Jan 2022 03:15:28 +0400 Subject: [PATCH] [processlist.go] Removed NewProcessList and AddProcess funcs. Passing ProcessList to MarshalXML by pointer instead of value. --- processlist.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/processlist.go b/processlist.go index 31f719a..8abc3de 100644 --- a/processlist.go +++ b/processlist.go @@ -7,17 +7,6 @@ import ( // ProcessList is a map of processes' statuses. type ProcessList map[string]bool -// NewProcessList returns a ProcessList with initialised map. -func NewProcessList() *ProcessList { - pl := make(ProcessList) - return &pl -} - -// AddProcess appends a process to a ProcessList -func (pl *ProcessList) AddProcess(name string, isup bool) { - (*pl)[name] = isup -} - // ProcessXMLEntry is a XML representation of a process stored in ProcessList. type ProcessXMLEntry struct { XMLName xml.Name @@ -26,8 +15,8 @@ type ProcessXMLEntry struct { } // MarshalXML implements Marshaler interface for a ProcessList. -func (l ProcessList) MarshalXML(e *xml.Encoder, start xml.StartElement) error { - if len(l) == 0 { +func (l *ProcessList) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if len(*l) == 0 { return nil } @@ -35,7 +24,7 @@ func (l ProcessList) MarshalXML(e *xml.Encoder, start xml.StartElement) error { return err } - for key, val := range l { + for key, val := range *l { e.Encode(ProcessXMLEntry{ XMLName: xml.Name{Local: "Process"}, Name: key,