Skip to content

Latest commit

 

History

History
77 lines (61 loc) · 1.84 KB

README.md

File metadata and controls

77 lines (61 loc) · 1.84 KB

libudev

Golang native implementation Udev library

Build Status Coverage Status Go Report Card GoDoc GitHub release

Installation

go get github.com/citilinkru/libudev

Usage

Scanning devices

sc := libudev.NewScanner()
err, devices := s.ScanDevices()

Filtering devices

m := matcher.NewMatcher()
m.SetStrategy(matcher.StrategyOr)
m.AddRule(matcher.NewRuleAttr("dev", "189:133"))
m.AddRule(matcher.NewRuleEnv("DEVNAME", "usb/lp0"))

filteredDevices := m.Match(devices)

Getting parent device

if device.Parent != nil {
    fmt.Printf("%s\n", device.Parent.Devpath)
}

Getting children devices

fmt.Printf("Count children devices %d\n", len(device.Children))

Features

  • 100% Native code
  • Without external dependencies
  • Code is covered by tests

Requirements

  • Need at least go1.13 or newer.

Documentation

You can read package documentation here or read tests.

Testing

Unit-tests:

go test -race -v ./...

Contributing

  • Fork
  • Write code
  • Run unit test: go test -v ./...
  • Run go vet: go vet -v ./...
  • Run go fmt: go fmt ./...
  • Commit changes
  • Create pull-request