Documentation ¶
Overview ¶
Package driverreg is a registry for all host driver implementation that can be automatically discovered.
Example ¶
package main import ( "fmt" "log" "periph.io/x/conn/v3/driver/driverreg" ) func main() { // Make sure periph is initialized. // TODO: Use host.Init(). It is not used in this example to prevent circular // go package import. state, err := driverreg.Init() if err != nil { log.Fatal(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. }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRegister ¶
MustRegister calls Register() and panics if registration fails.
This is the function to call in a driver's package init() function.
Types ¶
type DriverFailure ¶
DriverFailure is a driver that wasn't loaded, either because it was skipped or because it failed to load.
func (DriverFailure) String ¶
func (d DriverFailure) String() string
type State ¶
type State struct { Loaded []driver.Impl Skipped []DriverFailure Failed []DriverFailure }
State is the state of loaded device drivers.
Each list is sorted by the driver name.
Click to show internal directories.
Click to hide internal directories.