modulepackage
1.0.0
Repository: https://github.com/nexomichael/inputreader.git
Documentation: pkg.go.dev
# README
Golang implementation of "getchar" function which allows you to intercept entered symbols right after key presses.
Installation
Use the go
command:
go get github.com/NexoMichael/inputreader
Usage
package main
import (
"fmt"
"os"
"syscall"
input "github.com/NexoMichael/inputreader"
)
func main() {
reader, _ := input.NewInputReader(os.Stdin)
defer func() {
reader.Close()
}()
var b [1]byte
for {
n, err := reader.Read(b[:])
if err != nil || n == 0 {
return
}
fmt.Printf(" - code is %d\n\r", b[0])
switch syscall.Signal(b[0]) {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
return
}
}
}
Requirements
inputreader package requires Go >= 1.5.
Copyright
Copyright (C) 2018 by Mikhail Kochegarov [email protected].
UUID package releaed under MIT License. See LICENSE for details.
# Packages
No description provided by the author
# Functions
NewBuffer returns new InputLine buffer with default size equal to 4 KB.
NewInputReader returns a new InputReader for *os.File pipe.
# Structs
InputLine holds current eneterd line of symbols.
InputReader provides ReaderCloser interface for standart input or other input source pipe.