Browse Source

[processlist.go] Removed NewProcessList and AddProcess funcs.

Passing ProcessList to MarshalXML by pointer instead of value.
master
Alexander Andreev 7 months ago
parent
commit
006b832574
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F
  1. 17
      processlist.go

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

Loading…
Cancel
Save