Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/citilinkru/libudev
Golang native implementation udev library
https://github.com/citilinkru/libudev
go golang library libudev native udev uevent
Last synced: about 2 months ago
JSON representation
Golang native implementation udev library
- Host: GitHub
- URL: https://github.com/citilinkru/libudev
- Owner: citilinkru
- License: mit
- Created: 2018-03-01T18:18:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-25T18:51:49.000Z (over 4 years ago)
- Last Synced: 2024-06-18T20:18:14.801Z (7 months ago)
- Topics: go, golang, library, libudev, native, udev, uevent
- Language: Go
- Size: 28.3 KB
- Stars: 47
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-systemd - libudev (Go)
- awesome-systemd - libudev (Go)
README
# libudev
Golang native implementation Udev library[![Build Status](https://travis-ci.org/citilinkru/libudev.svg?branch=master)](https://travis-ci.org/citilinkru/libudev)
[![Coverage Status](https://coveralls.io/repos/github/citilinkru/libudev/badge.svg?branch=master)](https://coveralls.io/github/citilinkru/libudev?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/citilinkru/libudev)](https://goreportcard.com/report/github.com/citilinkru/libudev)
[![GoDoc](https://godoc.org/github.com/citilinkru/libudev?status.svg)](https://godoc.org/github.com/citilinkru/libudev)
[![GitHub release](https://img.shields.io/github/release/citilinkru/libudev.svg)](https://github.com/citilinkru/libudev/releases)Installation
------------
go get github.com/citilinkru/libudevUsage
-----### Scanning devices
```go
sc := libudev.NewScanner()
err, devices := s.ScanDevices()
```### Filtering devices
```go
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
```go
if device.Parent != nil {
fmt.Printf("%s\n", device.Parent.Devpath)
}
```### Getting children devices
```go
fmt.Printf("Count children devices %d\n", len(device.Children))
```Features
--------
* 100% Native code
* Without external dependencies
* Code is covered by testsRequirements
------------* Need at least `go1.13` or newer.
Documentation
-------------You can read package documentation [here](http:godoc.org/github.com/citilinkru/libudev) or read tests.
Testing
-------
Unit-tests:
```bash
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