初始版本.
Signed-off-by: chen.yang <chen.yang@yuzhen-iot.com>
This commit is contained in:
parent
eeac7cd272
commit
df0a9f758e
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
go.sum
|
||||
|
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module MUEvent
|
||||
|
||||
go 1.16
|
||||
|
||||
require github.com/deniswernert/udev v0.0.0-20170418162847-a12666f7b5a1
|
34
main.go
Normal file
34
main.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/deniswernert/udev"
|
||||
)
|
||||
|
||||
var UNotify chan *udev.UEvent
|
||||
|
||||
func Mon() {
|
||||
for {
|
||||
uevent := <-UNotify
|
||||
|
||||
log.Println("UEvent.Action: ", uevent.Action)
|
||||
log.Println("UEvent.Devpath: ", uevent.Devpath)
|
||||
log.Println("UEvent.Env: ", uevent.Env)
|
||||
log.Println()
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
UNotify = make(chan *udev.UEvent, 128)
|
||||
mon, e := udev.NewMonitor()
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
go Mon()
|
||||
mon.Monitor(UNotify)
|
||||
for {
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user