Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
gc "code.google.com/p/goncurses"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s, err := gc.Init()
|
||||
if err != nil {
|
||||
log.Fatal("init:", err)
|
||||
}
|
||||
defer gc.End()
|
||||
gc.Cursor(0)
|
||||
s.Move(20, 0)
|
||||
s.Print("Key check in ")
|
||||
for i := 3; i >= 1; i-- {
|
||||
s.MovePrint(20, 13, i)
|
||||
s.Refresh()
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
// stackoverflow.com/questions/43965556/how-to-read-a-key-in-go-but-continue-application-if-no-key-pressed-within-x-seco
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"log"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
var reader = bufio.NewReader(os.Stdin)
|
||||
|
||||
func readKey(input chan rune) {
|
||||
char, _, err := reader.ReadRune()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
input <- char
|
||||
}
|
||||
|
||||
func main() {
|
||||
input := make(chan rune, 1)
|
||||
fmt.Println("Checking keyboard input...")
|
||||
go readKey(input)
|
||||
select {
|
||||
case i := <-input:
|
||||
fmt.Printf("Input : %v\n", i)
|
||||
case <-time.After(5000 * time.Millisecond):
|
||||
fmt.Println("Time out!")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue