[processlist.go] Removed NewProcessList and AddProcess funcs.
Passing ProcessList to MarshalXML by pointer instead of value.
This commit is contained in:
parent
e19d69b845
commit
006b832574
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user