1
0
Fork 0

[processlist.go] Removed NewProcessList and AddProcess funcs.

Passing ProcessList to MarshalXML by pointer instead of value.
This commit is contained in:
Alexander Andreev 2022-01-06 03:15:28 +04:00
parent e19d69b845
commit 006b832574
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F
1 changed files with 3 additions and 14 deletions

View File

@ -7,17 +7,6 @@ import (
// ProcessList is a map of processes' statuses. // ProcessList is a map of processes' statuses.
type ProcessList map[string]bool 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. // ProcessXMLEntry is a XML representation of a process stored in ProcessList.
type ProcessXMLEntry struct { type ProcessXMLEntry struct {
XMLName xml.Name XMLName xml.Name
@ -26,8 +15,8 @@ type ProcessXMLEntry struct {
} }
// MarshalXML implements Marshaler interface for a ProcessList. // MarshalXML implements Marshaler interface for a ProcessList.
func (l ProcessList) MarshalXML(e *xml.Encoder, start xml.StartElement) error { func (l *ProcessList) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if len(l) == 0 { if len(*l) == 0 {
return nil return nil
} }
@ -35,7 +24,7 @@ func (l ProcessList) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return err return err
} }
for key, val := range l { for key, val := range *l {
e.Encode(ProcessXMLEntry{ e.Encode(ProcessXMLEntry{
XMLName: xml.Name{Local: "Process"}, XMLName: xml.Name{Local: "Process"},
Name: key, Name: key,