shell/input.go

20 lines
274 B
Go
Raw Normal View History

2023-03-19 13:08:11 +01:00
package main
import (
"os"
)
func handleInput() <-chan byte {
ch := make(chan byte)
go func(ch chan byte) {
data := make([]byte, 1)
for _, err := os.Stdin.Read(data); err == nil; _, err = os.Stdin.Read(data) {
ch <- data[0]
}
close(ch)
}(ch)
return ch
}