Add testinp binary
This commit is contained in:
parent
e666ac8e3b
commit
0ab01ad7f5
3
Makefile
3
Makefile
|
@ -13,6 +13,9 @@ server:
|
|||
client:
|
||||
go build -o ./bin/$@ ./cmd/$@
|
||||
|
||||
testinp:
|
||||
go build -o ./bin/$@ ./cmd/$@
|
||||
|
||||
gen_test_certs:
|
||||
openssl ecparam -genkey -name prime256v1 -out server.key
|
||||
openssl req -new -x509 -key server.key -out server.pem -days 3650
|
||||
|
|
30
cmd/testinp/main.go
Normal file
30
cmd/testinp/main.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
func main() {
|
||||
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer term.Restore(int(os.Stdin.Fd()), oldState)
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
for {
|
||||
r, _, err := reader.ReadRune()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Read %c ; %d as rune\r\n", r, r)
|
||||
|
||||
// CTRL + C
|
||||
if r == 3 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user