mc root source folder cleanup
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Stdin struct {
|
||||
Val string
|
||||
}
|
||||
|
||||
func StartListingStdin(l *Loop) {
|
||||
l.RegisterEventSource(func() (chSending <-chan any) {
|
||||
ch := make(chan any)
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
ctx := l.Ctx
|
||||
for scanner.Scan() {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
ch <- Stdin{scanner.Text()}
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
ch <- err
|
||||
}
|
||||
}()
|
||||
chSending = ch
|
||||
return
|
||||
}())
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user