mirror of
https://github.com/periph/host.git
synced 2026-10-23 05:09:34 +03:00
Expose fix, verify, test, and help through consistent Make targets, with locked uv tools, EditorConfig, versioned hooks, shared binary checks, and generated agent file indexes. Apply safe lint fixes and formatting quietly while preserving diagnostics and failure exit codes. Require Go 1.26 and read CI toolchains from go.mod. Track lint and license tools in the root module; run pinned actionlint separately because of YAML dependency conflicts. Run vet through golangci-lint and retain distinct compile/link and module-tidiness checks. Refresh Actions and share setup where applicable. Ignore Codecov and coverage artifacts on Unix and Windows while keeping plain Git status checks for tracked changes and unexpected output. Run historical benchmark comparisons and their tool setup only on Ubuntu. Preserve platform and architecture coverage and downstream devices/cmd consumer gates while sharing runtime and static-check setup. Validation: make fix and make verify pass. Applicable test, generation, race, cross-build, and consumer checks passed during implementation. Formatter diagnostic fixtures, ignore-rule fixtures, index checks, and staged hooks pass. Native hosted OS and physical hardware execution remain outside local validation. Squashing preserves the validated file tree exactly.
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
// 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.
|
|
|
|
// Example initializing host hardware drivers.
|
|
|
|
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.
|
|
}
|