@@ -21,26 +21,28 @@ import "fmt"
2121// list is a discoverer that contains a list of Discoverers. The output of the
2222// Mounts functions is the concatenation of the output for each of the
2323// elements in the list.
24- type list struct {
25- discoverers []Discover
26- }
24+ type list []Discover
2725
2826var _ Discover = (* list )(nil )
2927
3028// Merge creates a discoverer that is the composite of a list of discoverers.
31- func Merge (d ... Discover ) Discover {
32- l := list {
33- discoverers : d ,
29+ func Merge (discoverers ... Discover ) Discover {
30+ var l list
31+ for _ , d := range discoverers {
32+ if d == nil {
33+ continue
34+ }
35+ l = append (l , d )
3436 }
3537
36- return & l
38+ return l
3739}
3840
3941// Devices returns all devices from the included discoverers
4042func (d list ) Devices () ([]Device , error ) {
4143 var allDevices []Device
4244
43- for i , di := range d . discoverers {
45+ for i , di := range d {
4446 devices , err := di .Devices ()
4547 if err != nil {
4648 return nil , fmt .Errorf ("error discovering devices for discoverer %v: %v" , i , err )
@@ -55,7 +57,7 @@ func (d list) Devices() ([]Device, error) {
5557func (d list ) Mounts () ([]Mount , error ) {
5658 var allMounts []Mount
5759
58- for i , di := range d . discoverers {
60+ for i , di := range d {
5961 mounts , err := di .Mounts ()
6062 if err != nil {
6163 return nil , fmt .Errorf ("error discovering mounts for discoverer %v: %v" , i , err )
@@ -70,7 +72,7 @@ func (d list) Mounts() ([]Mount, error) {
7072func (d list ) Hooks () ([]Hook , error ) {
7173 var allHooks []Hook
7274
73- for i , di := range d . discoverers {
75+ for i , di := range d {
7476 hooks , err := di .Hooks ()
7577 if err != nil {
7678 return nil , fmt .Errorf ("error discovering hooks for discoverer %v: %v" , i , err )
0 commit comments