I use the native golang package "container/list" to manage inotify event in a stack. When I access at stack's item, I have a fail with the type (I think).
import (
"golang.org/x/exp/inotify"
"container/list"
"log"
"fmt"
)
func main() {
stack := list.New()
watcher, err := inotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
err = watcher.Watch(os.Args[1])
if err != nil {
log.Fatal(err)
}
for {
select {
case ev := <-watcher.Event:
stack.PushFront(ev)
fmt.Printf("%#v
", ev)
}
foo := stack.Front().Value
fmt.Printf("%#v
", foo)
log.Println("Name: ", foo.Name)
}
}
When I dump ev variable, the object type is &inotify.Event. When I pop one item and I dump the variable, my object type is &inotify.Event.
With the error message I think it's a problem with type object accept by interface but I don't find how define type.