1
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

View File

@ -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,