-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
40 lines (36 loc) · 920 Bytes
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package mxio
import (
"fmt"
"net"
"github.com/arolek/mxio"
)
func ExampleAutoSearch() {
// This will get all the devices on the first up and broadcastable interface.
devices, err := mxio.AutoSearch()
if err != nil {
// Handle error correctly.
fmt.Printf("Could not find devices because of %v\n", err)
return
}
fmt.Printf("Found %v devices:\n", len(devices))
for i, d := range devices {
fmt.Printf("Device %v :\n%v\n", i, d)
}
}
func ExampleAutoSearch_Interface() {
// Search on the first Interface, for only the E1200_SERIES of devices
m := mxio.Mxio{
IF: net.Interfaces()[0],
DeviceType: mxio.E1200_SERIES,
}
devices, err := m.AutoSearch()
if err != nil {
// Handle error correctly.
fmt.Printf("Could not find devices because of %v\n", err)
return
}
fmt.Printf("Found %v devices:\n", len(devices))
for i, d := range devices {
fmt.Printf("Device %v :\n%v\n", i, d)
}
}