From 69d76cd5e4524dddbe37ceaf520ed7b5d0d4b92b Mon Sep 17 00:00:00 2001 From: John Beisley Date: Sun, 29 Sep 2013 15:59:53 +0100 Subject: [PATCH] Remove some pointer indirections in device.go. --- cmd/discoverigd/discoverigd.go | 6 +++--- device.go | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/discoverigd/discoverigd.go b/cmd/discoverigd/discoverigd.go index 4f2274f..002c338 100644 --- a/cmd/discoverigd/discoverigd.go +++ b/cmd/discoverigd/discoverigd.go @@ -30,8 +30,8 @@ func displayDevice(indent indentLevel, device *goupnp.Device) { } } } - for _, subdev := range device.Devices { - displayDevice(indent+1, subdev) + for i := range device.Devices { + displayDevice(indent+1, &device.Devices[i]) } } @@ -44,7 +44,7 @@ func main() { if maybeRootDevice.Err != nil { fmt.Println(maybeRootDevice.Err) } else { - displayDevice(0, maybeRootDevice.Root.Device) + displayDevice(0, &maybeRootDevice.Root.Device) } } } diff --git a/device.go b/device.go index a4ddfbe..a05970a 100644 --- a/device.go +++ b/device.go @@ -23,7 +23,7 @@ type RootDevice struct { SpecVersion SpecVersion `xml:"specVersion"` URLBase url.URL `xml:"-"` URLBaseStr string `xml:"URLBase"` - Device *Device `xml:"device"` + Device Device `xml:"device"` } func (root *RootDevice) SetURLBase(urlBase *url.URL) { @@ -38,20 +38,20 @@ type SpecVersion struct { } type Device struct { - DeviceType string `xml:"deviceType"` - FriendlyName string `xml:"friendlyName"` - Manufacturer string `xml:"manufacturer"` - ManufacturerURL URLField `xml:"manufacturerURL"` - ModelDescription string `xml:"modelDescription"` - ModelName string `xml:"modelName"` - ModelNumber string `xml:"modelNumber"` - ModelURL URLField `xml:"modelURL"` - SerialNumber string `xml:"serialNumber"` - UDN string `xml:"UDN"` - UPC string `xml:"UPC,omitempty"` - Icons []*Icon `xml:"iconList>icon,omitempty"` - Services []*Service `xml:"serviceList>service,omitempty"` - Devices []*Device `xml:"deviceList>device,omitempty"` + DeviceType string `xml:"deviceType"` + FriendlyName string `xml:"friendlyName"` + Manufacturer string `xml:"manufacturer"` + ManufacturerURL URLField `xml:"manufacturerURL"` + ModelDescription string `xml:"modelDescription"` + ModelName string `xml:"modelName"` + ModelNumber string `xml:"modelNumber"` + ModelURL URLField `xml:"modelURL"` + SerialNumber string `xml:"serialNumber"` + UDN string `xml:"UDN"` + UPC string `xml:"UPC,omitempty"` + Icons []Icon `xml:"iconList>icon,omitempty"` + Services []Service `xml:"serviceList>service,omitempty"` + Devices []Device `xml:"deviceList>device,omitempty"` // Extra observed elements: PresentationURL URLField `xml:"presentationURL"`