Skip to content

Golang native implementation udev library

License

Notifications You must be signed in to change notification settings

oakmound/libudev

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libudev

Golang native implementation Udev library

Build Status Coverage Status Go Report Card GoDoc GitHub release

Installation

go get github.com/oakmound/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.10 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

About

Golang native implementation udev library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%