dread

package module
v0.0.0-...-12fe57d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2017 License: MIT Imports: 3 Imported by: 0

README

dread

Go package for directly reading a rune (char) from stdin.

Normally reading from Stdin waits for the user to press enter to enable the user to correct errors in the line. If you want to read the next character directly when it is typed, you can use this package.

Please be aware that enabling raw mode for the terminal disables all convenience functions of your terminal, including:

  • Local echo
  • Pasting text

Performance

The performance is terrible. Do not use this to process large amounts of data. If you want to do that, please use this package: https://godoc.org/golang.org/x/crypto/ssh/terminal

Example

package main

import (
	"log"

	"github.com/noxer/dread"
)

func main() {
  // Read 10 runes from and print them on the command line.
	for i := 0; i < 10; i++ {
		r, err := dread.ReadRune()
		if err != nil {
			log.Fatalf("%d: Error: %s\n", i, err)
		}
		log.Printf("%d: Rune: %c (%[2]U)", i, r)
	}

	log.Println("Done.")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadRune

func ReadRune() (rune, error)

ReadRune reads a single rune from stdin.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL