-
Notifications
You must be signed in to change notification settings - Fork 33
/
example_test.go
41 lines (33 loc) · 1.03 KB
/
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
41
// Copyright 2018 The Periph Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
package host_test
import (
"fmt"
"log"
"periph.io/x/host/v3"
)
func ExampleInit() {
// Make sure periph is initialized.
state, err := host.Init()
if err != nil {
log.Fatalf("failed to initialize periph: %v", err)
}
// Prints the loaded driver.
fmt.Printf("Using drivers:\n")
for _, driver := range state.Loaded {
fmt.Printf("- %s\n", driver)
}
// Prints the driver that were skipped as irrelevant on the platform.
fmt.Printf("Drivers skipped:\n")
for _, failure := range state.Skipped {
fmt.Printf("- %s: %s\n", failure.D, failure.Err)
}
// Having drivers failing to load may not require process termination. It
// is possible to continue to run in partial failure mode.
fmt.Printf("Drivers failed to load:\n")
for _, failure := range state.Failed {
fmt.Printf("- %s: %v\n", failure.D, failure.Err)
}
// Use pins, buses, devices, etc.
}