ducky/devices
ducky/devices/devices.go
Add doc comments to all our exported types. It makes golint happy, and it's a good thing to do. It's kind of shameful that we went so long without them. Oops.
1.1 --- a/devices.go Fri Nov 27 11:32:15 2015 -0800 1.2 +++ b/devices.go Sat Nov 28 18:26:03 2015 -0800 1.3 @@ -78,6 +78,9 @@ 1.4 ListDevicesByOwner(user uuid.ID, c context.Context) ([]Device, error) 1.5 } 1.6 1.7 +// ErrDeviceAlreadyExists is returned when a Device is added to a Storer, but a 1.8 +// Device with the same ID already exists in the Storer. The ID underlying 1.9 +// ErrDeviceAlreadyExists will hold the ID that already exists. 1.10 type ErrDeviceAlreadyExists uuid.ID 1.11 1.12 func (e ErrDeviceAlreadyExists) Error() string { 1.13 @@ -207,6 +210,8 @@ 1.14 return devices, err 1.15 } 1.16 1.17 +// ToMap transforms the passed slice into a map by using the String method of 1.18 +// each Device's ID as the key, and the Device as the value. 1.19 func ToMap(devices []Device) map[string]Device { 1.20 results := make(map[string]Device, len(devices)) 1.21 for _, device := range devices { 1.22 @@ -215,6 +220,7 @@ 1.23 return results 1.24 } 1.25 1.26 +// ToSlice transforms the passed map of Devices into a slice of Devices. 1.27 func ToSlice(devices map[string]Device) []Device { 1.28 results := make([]Device, 0, len(devices)) 1.29 for _, device := range devices {